Scaling, Shearing, Translating, and Rotating a Drawn Image

See also The Quintessential Drawing Program and Reading an Image or Icon from a File.
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AffineTransform tx = new AffineTransform(); double scalex = .5; double scaley = 1; tx.scale(scalex, scaley); double shiftx = .1; double shifty = .3; tx.shear(shiftx, shifty); double x = 50; double y = 50; tx.translate(x, y); double radians = -Math.PI/4; tx.rotate(radians); g2d.drawImage(image, tx, this); }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.