How do I scale, shear, translate, and/or rotate an image?
Created May 4, 2012
John Zukowski Use the AffineTransform class, and pass it along to the drawImage() method.
- Create: AffineTransform trans = new AffineTransform()
- Scale: trans.scale(scalex, scaley)
- Shear: trans.shear(shiftx, shifty)
- Translate: trans.translate(deltax, deltay)
- Rotate: trans.rotate(radians)
- Draw: g2d.drawImage(image, trans, this)