atom feed9 messages in net.java.dev.jai-imageio.interestRE: [JAI-IMAGEIO] Rescaling image to ...
FromSent OnAttachments
mja...@union06.deNov 5, 2007 10:48 pm 
Bob DeenNov 6, 2007 9:18 am 
Fork LabsNov 6, 2007 9:52 am 
Bob DeenNov 6, 2007 9:58 am 
jai-...@javadesktop.orgNov 6, 2007 6:09 pm 
Fork LabsNov 7, 2007 7:56 am 
Bob DeenNov 7, 2007 2:45 pm 
jai-...@javadesktop.orgNov 7, 2007 4:25 pm 
mja...@union06.deNov 7, 2007 10:57 pm 
Subject:RE: [JAI-IMAGEIO] Rescaling image to arbitrary sizes (without preserving aspect ratio)
From:mja...@union06.de (mja@union06.de)
Date:Nov 5, 2007 10:48:19 pm
List:net.java.dev.jai-imageio.interest

Hi Rafael,

you should better ask JAI questions to JAI-INTEREST and not JAI-IMAGEIO. This is only for image reading/writing.

However there is no method in JAI scaling to a fixed pixel size. You have to calculate the scale factors yourself. You don't know if the source image will fit into the target boundings so calculate the maximum scale factor of x/y and use the same factor for both to keep aspect ratio.

Kind regards, Marco

Hi, rajendraranabhat

I've changed the subject

Actually I didn't. Sorry. Don't drink and post. Here goes.

so people can see what the message is about. I'd also gather this is NOT related to ImageIO, but...

Hi i could scale the image with keeping the aspect ratio the same but i was thinking if we can scale the image by fixed height and width.For instance i have image of 120*100(width*height) and now i want it to make it some 80*90(width*height).Is it possible?For scaling the image with fixed ratio here goes my code.Sorry i am bit new to this JAI or Image IO:)

/* * This method rescales an image to 300,300 pixels using the JAI scale * operator. */ private RenderedImage rescale(RenderedImage i) { float baseSize = 300; float scaleW = ((float)baseSize)/i.getWidth(); float scaleH = ((float)baseSize)/i.getHeight(); // Scales the original image ParameterBlock pb = new ParameterBlock(); pb.addSource(i); pb.add(scaleW); pb.add(scaleH); pb.add(0.0F); pb.add(0.0F); pb.add(new InterpolationNearest()); // Creates a new, scaled image and uses it on the DisplayJAI component return JAI.create("scale", pb); }

Rafael