views:

260

answers:

1

When I read a JPEG from disk, Java sometimes gives me a BufferedImage whose getType() returns TYPE_CUSTOM -- that is, it has a custom color model. I'd like to resize this BufferedImage but I'm not sure how to construct the destination object. Can someone please provide sample code for using the following constructor?

BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable properties)

I would like to create a BufferedImage of the same type as the source, just bigger, and transfer the contents over. Any ideas?

+2  A: 

Answering my own question, it looks like ImageTypeSpecifier is the answer. Specifically:

ImageTypeSpecifier.createFromRenderedImage(RenderedImage image) ImageTypeSpecifier.createBufferedImage(int width, int height)

Gili