Update Image width and height

Hello Friends,

I Create One java class for Getting an image from hard drive and Update its width and Height of that Image through AffineTransform and then after save it back to hard drive through BufferedImage.

But when i save my image into hard drive it is not display proper manner.

That means after updating the image i can not get its updated width and Height from AffineTransform.

my code is as bellow :

publicstaticvoid main(String[] args)

{

AffineTransform tx =new AffineTransform();

float scalingFactor = 1.0f;

Dimension size =new Dimension( 600, 600 );

Point origin =new Point( size.width / 2, size.height / 2 );

File f =new File("aa.jpg");

try{

BufferedImage bufi = ImageIO.read(f);

tx.translate( origin.x, origin.y );

scalingFactor += 2.0;

tx.scale( scalingFactor, scalingFactor );

tx.setToScale(scalingFactor, scalingFactor);

//BufferedImage bi = new BufferedImage(100, 180, BufferedImage.TYPE_INT_RGB);

BufferedImage bi =new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB);

Graphics2D big = bi.createGraphics();

big.drawImage( bufi, tx,null );

//big.drawImage(bufi, 0, 0, null);

ImageIO.write(bi,"jpg",new File("aaa.jpg"));

OutputStream out =new FileOutputStream("aa2.jpg");

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

encoder.encode(bi);

f =null;

bufi =null;

bi =null;

out.close();//

}catch (Exception ex){

ex.printStackTrace();

}

}

Please give me right solution of this as soon as possible.

Thanks

Anup A. Patel.

[2619 byte] By [AnupPatela] at [2007-11-27 11:37:49]
# 1

BufferedImage bi = new BufferedImage(bufi.getWidth()*scalingFactor, bufi.getHeight()*scalingFactor, BufferedImage.TYPE_INT_RGB);

Also this line overrides the previous 2 lines setting translation and scale: tx.setToScale(scalingFactor, scalingFactor);

So there's no need for them.

And why are you writing the jpeg twice using JPEGImageEncoder and ImageIO?

Rodney_McKaya at 2007-7-29 17:16:38 > top of Java-index,Security,Cryptography...
# 2

thank you very much,

i understand your reply.... it is work properly

if any else query regarding this then i will ping you.

Again thank you very much

AnupPatela at 2007-7-29 17:16:38 > top of Java-index,Security,Cryptography...