how to scale image

i am working with JAI and have to scale image. it has to be enlarged or shrinked. supposed i have image and i want to increase it's size upto 200% of actual size(not memory size).

i tried this

// Create a ParameterBlock and specify the source and

// parameters

ParameterBlock pb =new ParameterBlock();

pb.addSource(im);// The source image

pb.add(1.2);// The xScale

pb.add(1.2);// The yScale

pb.add(0.0F);// The x translation

pb.add(0.0F);// The y translation

pb.add(new InterpolationNearest());// The interpolation

// Create the scale operation

im = JAI.create("scale", pb,null);

but facing exception.

Exception in thread "main" java.lang.IllegalArgumentException: Scale - Parameter value`s class ([D) is not an instance of the parameter class (java.lang.Float) for parameter "xScale".

Any thoughts or suggestions?

Prashant

[1339 byte] By [Prashant_SDNa] at [2007-11-26 16:05:33]
# 1

Use BufferedImage and drawImage with scale, it would be much easier.

double scale = 1.2;

BufferedImage image = new BufferedImage((int)Math.round(im.getWidth()*scale), (int)Math.round(im.getHeight()*scale), BufferedImage.TYPE_INT_RGB);

image.createGraphics().drawImage(im, 0, 0, image.getWidth(), image.getHeight(), null);

Rodney_McKaya at 2007-7-8 22:27:34 > top of Java-index,Security,Cryptography...