How do I scale, shear, translate, and/or rotate an image?

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)
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact