Velocity Reviews

Velocity Reviews (
-   Java (
-   -   jai to create a grayscale img from any imagetype (

harryos 07-18-2008 08:34 PM

jai to create a grayscale img from any imagetype

I would like to use jai1.1 to read images of any type.Some of the
images may be grayscale pgm , truecolor png or whatever ...

i tried this

public void makeMyImage(String imagename){
RenderedImage im0=JAI.create("fileload",imagename);
Raster rastPic = im0.getData();
int widthPix = rastPic.getWidth();
int heightPix = rastPic.getHeight();



in order to use ColorConvertOp i guess i will need to create a
BufferedImage from this .so i try to find if the color type is
TrueColor and make a BufferedImage and then apply ColorConvertOp.But i
don't know which value i should give for the imageType in
BufferedImage constructor.can somebody help with that?

BufferedImage orig;
orig=new BufferedImage(widthPix, heightPix,??);


after this i can put the values from Raster into this image
orig.setData( rastPic) ;

then i can apply the ColorConvertOp and create a grayscale

I don't know if this is the correct way to deal with image types not
supported in std java image api. i couldn't find many examples to
learn from..if some experts can advise it would be a great help


All times are GMT. The time now is 10:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.