Image Quality Gets Ruined In Java Graphics2D Rotate

前端 未结 2 1626
不知归路
不知归路 2021-01-15 05:01

I am experiencing an issue with rotating an Image with the Graphics2D rotate method.

Here\'s an image of the issue I\'m having:

相关标签:
2条回答
  • 2021-01-15 05:36

    I know this is a pretty old question but for anyone looking to do something similar try putting the following code before your g.drawImage

    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    

    That should help to make the image look a better.

    0 讨论(0)
  • 2021-01-15 05:48

    So currently as the ball moves, you rotate the image a few degrees and overwrite the original image with the new one? Each time the image is rotated, a tiny bit of distortion is added; over many rotations, the distortion is compounded.

    Instead, just keep the original image in memory and also store the number of degrees it should appear to be rotated on screen. Then each time you render it, rotate the original image by the current number of degrees.

    0 讨论(0)
提交回复
热议问题