jai to create a grayscale img from any imagetype

H

harryos

hi

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;
if(im0.getProperty("color_type")=="Truecolor"){
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
BufferedImage

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

harry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top