PlanerImage .getAsBufferedImage( Rectangle, ColorModel )
Hi,
If I use JAI to get a PlanerImage for a file on Disk, then want to get a BufferedImage for a sub section of that Image, I use the following:
FileSeekableStream stream = stream =new FileSeekableStream("FILENAME" );
ParameterBlock params =new ParameterBlock();
params.add( stream );
RenderedOp img = JAI.create( format, params );
BufferedImage bi = img.getAsBufferedImage(
new Rectangle( (int) vr.getMinX(), (int) vr.getMinY(),
(int) vr.getWidth(), (int) vr.getHeight() ), cm );
//Later on
g.drawImage( bi, x, y, w, h,null );
//Throws exceptions !
Now, the cm (ColorModel) Variable seems to be the issue:
If I use ColorModel cm = ColorModel.getRGBdefault(); I get the folloing error on render.
java.lang.IllegalArgumentException: The supplied ColorModel is not compatible with this image`s SampleModel.
However, If I use null for the ColorModel, I get the following error:
java.awt.image.ImagingOpException: Unable to transform src image
at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:263)
Does anyone have any suggestions ?
I'm really stumped on a critical product point.
Cheers,
Ronan

