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

[1599 byte] By [bilcoa] at [2007-10-2 13:53:26]
# 1
Bump.
bilcoa at 2007-7-13 11:55:55 > top of Java-index,Security,Cryptography...