Drawing an image using sub-pixel level accuracy using Graphics2D

前端 未结 4 1226
北荒
北荒 2021-02-15 14:48

I am currently attempting to draw images on the screen at a regular rate like in a video game.

Unfortunately, because of the rate at which the image is moving, some fram

4条回答
  •  走了就别回头了
    2021-02-15 15:27

    Change the resolution of your image accordingly, there's no such thing as a bitmap with sub-pixel coordinates, so basically what you can do is create an in memory image larger than what you want rendered to the screen, but allows you "sub-pixel" accuracy.

    When you draw to the larger image in memory, you copy and resample that into the smaller render visible to the end user.

    For example: a 100x100 image and it's 50x50 resized / resampled counterpart:

    resampling

    See: http://en.wikipedia.org/wiki/Resampling_%28bitmap%29

提交回复
热议问题