Image scaling

can any one tell or give me code of how to scale a big image to smaller image and smaller image to bigger one with out loosing the clarity.thanks in advance
[170 byte] By [Sarjaya] at [2007-10-2 16:48:32]
# 1
[url http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html]Scaling, Shearing, Translating, and Rotating a Buffered Image[/url]
weebiba at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 2

thanks for the when i run that it throws exception "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space"

my code is as below:

BufferedImage buggImg = ImageIO.read(new File("Image1.jpg"));

AffineTransform tx = new AffineTransform();

tx.scale(200, 150);

AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);

buggImg = op.filter(buggImg, null);

ImageIO.write(scale(buggImg, 200), "jpg", new File("image2.jpg"));

Sarjaya at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 3
That's because your output image is too big.
weebiba at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 4
size of Image1.jpg is around 53x72
Sarjaya at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 5
thanks weebib , but i want to scale image both ways i.e smaller to bigger and bigger to smaller
Sarjaya at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 6
> size of Image1.jpg is around 53x72... and the resulting scaled image is around (53 * 200) x (72 * 150) = 10600 x 10800I guess you meant a scale factor of 2.0 x 1.5
Franck_Lefevrea at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 7
what i mean to say is converting 53x72 image to 72x53 sized image...
Sarjaya at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...
# 8
> what i mean to say is converting 53x72 image to> 72x53 sized image...then use: tx.scale(72/53f, 53/72f);
Franck_Lefevrea at 2007-7-13 17:59:38 > top of Java-index,Desktop,Core GUI APIs...