Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert planarimage to image  RSS feed

 
Manu Herrero Manu Herrero
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every one?
I have a renderedop or planarimage object, I'm trying to convert this renderedop image to image object.
My code is:
RenderedOp rImage = JAI.create("url", new java.net.URL(urlImage));
BufferedImage bImage = rImage.getAsBufferedImage();
Image image = bImage.getScaledInstance(bImage.getWidth(),bImage.getHeight(),java.awt.Image.SCALE_DEFAULT);

But it is appearing this error:
java.lang.IllegalArgumentException: The specified ColorModel is incompatible with the image SampleModel.
at javax.media.jai.PlanarImage.setImageLayout(PlanarImage.java:493)
at javax.media.jai.PlanarImage.<init>(PlanarImage.java:376)
...
Any idea?
How can I convert RenderedOp object into Image class object?
 
Richie Duggan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manu Herrero Manu Herrero:
Hi every one?

I have a renderedop or planarimage object, I'm trying to convert this renderedop image to image object.
My code is:

RenderedOp rImage = JAI.create("url", new java.net.URL(urlImage));
BufferedImage bImage = rImage.getAsBufferedImage();
Image image = bImage.getScaledInstance(bImage.getWidth(),bImage.getHeight(),java.awt.Image.SCALE_DEFAULT);


But it is appearing this error:

java.lang.IllegalArgumentException: The specified ColorModel is incompatible with the image SampleModel.
at javax.media.jai.PlanarImage.setImageLayout(PlanarImage.java:493)
at javax.media.jai.PlanarImage.<init>(PlanarImage.java:376)
...
Any idea?
How can I convert RenderedOp object into Image class object?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!