R
Rajesh.Rapaka
HI all,
I am trying to use java's affine transform method for my zoom - in and
zoom - out functions. This is a small piece of code that i've written
in my "mouseClicked" mouse lisetner function.
AffineTransform tx = new AffineTransform();
AffineTransformOp op;
if (me.isMetaDown()) {
tx.scale(0.5, 0.5);
}
else {
tx.scale(1.5, 1.5);
}
op = new AffineTransformOp(tx,
AffineTransformOp.
TYPE_NEAREST_NEIGHBOR);
try {
bufImage = op.filter(bufImage, null);
}
catch (Exception e) {
e.printStackTrace();
}
It's working fine. But the more I do the zoom-in and zoom-out clicks
the images gets distorted. I understand its because of the scale. i am
not able to get back to the exact zoomed-out place after I zoomed-in.
for example lets say I zoomed from 5 to 10. and when i say zoom-out it
might be getting back to 3 or might be getting back to 8. but not to 5.
How can I solve this. What could be the exact values ? How can we know
it ?
plz help. Thanks in Advance.
regards,
Rajesh Rapaka.
I am trying to use java's affine transform method for my zoom - in and
zoom - out functions. This is a small piece of code that i've written
in my "mouseClicked" mouse lisetner function.
AffineTransform tx = new AffineTransform();
AffineTransformOp op;
if (me.isMetaDown()) {
tx.scale(0.5, 0.5);
}
else {
tx.scale(1.5, 1.5);
}
op = new AffineTransformOp(tx,
AffineTransformOp.
TYPE_NEAREST_NEIGHBOR);
try {
bufImage = op.filter(bufImage, null);
}
catch (Exception e) {
e.printStackTrace();
}
It's working fine. But the more I do the zoom-in and zoom-out clicks
the images gets distorted. I understand its because of the scale. i am
not able to get back to the exact zoomed-out place after I zoomed-in.
for example lets say I zoomed from 5 to 10. and when i say zoom-out it
might be getting back to 3 or might be getting back to 8. but not to 5.
How can I solve this. What could be the exact values ? How can we know
it ?
plz help. Thanks in Advance.
regards,
Rajesh Rapaka.