jai to create a grayscale img from any imagetype

Discussion in 'Java' started by harryos, Jul 18, 2008.

  1. harryos

    harryos Guest

    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
     
    harryos, Jul 18, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    545
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. Philipp Lenssen

    Problem: <img></img>

    Philipp Lenssen, Jun 27, 2005, in forum: XML
    Replies:
    15
    Views:
    808
    David Håsäther
    Jul 3, 2005
  3. Java_New
    Replies:
    5
    Views:
    3,009
    Andrey Kuznetsov
    May 27, 2006
  4. Speed
    Replies:
    5
    Views:
    440
    Speed
    Mar 11, 2007
  5. harryos
    Replies:
    0
    Views:
    616
    harryos
    Jul 19, 2008
Loading...

Share This Page