Flip Image with Graphics2D

前端 未结 5 974
一个人的身影
一个人的身影 2020-12-08 10:27

I\'ve been trying to figure out how to flip an image for a while, but haven\'t figured out yet.

I\'m using Graphics2D to draw an Image with

5条回答
  •  一生所求
    2020-12-08 11:23

    The easiest way to flip the image is by negative scaling it. Example:

    g2.drawImage(image, x + width, y, -width, height, null);
    

    That will flip it horizontally. This will flip it vertically:

    g2.drawImage(image, x, y + height, width, -height, null);
    

提交回复
热议问题