Question about AffineTransform
How can I keep the image effects when an image is flipped ? I can successfully zoom and rotate an image. But when the image is flipped, the image size and orientation is set to the original image first and then it is flipped. For example, if the image is zoomed in and then flipped vertically, the image is set back to the original size .
AffineTransform tx=new AffineTransform();
AffineTransformOp op=null;
//zoom in/out
public void zoomObj(int z)
{
if ( z > 0 )
zv=1.1;
else
zv=0.9;
tx.scale(zv,zv);
op=new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
}
public void rotateObj()
{
tx.rotate(Math.PI/2.0,0.0,0.0);
op=new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
}
public void filpObj(int vh)
{
if ( vh == -1 )
{
tx.setToScale(1,-1); // flip up vertically
tx.translate(0, -h); // h – the height of the image
}
op = new AffineTransformOp(tx,AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
}
public void paintComponent(Graphics g)
{
// super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.drawImage(image,op,x,y);
}
Thanks
Jay