python - 图像在 Pygame 中旋转,同时保持平滑的边缘

标签 python image pygame smoothing

我想旋转图像并保持边缘平滑。

原来是这样的

original image

旋转后

rotated image

我使用的代码看起来像

def rot_center(self, image, angle):
   """rotate an image while keeping its center and size"""
   orig_rect = image.get_rect()
   rot_image = pygame.transform.rotate(image, angle)
   rot_rect = orig_rect.copy()
   rot_rect.center = rot_image.get_rect().center
   rot_image = rot_image.subsurface(rot_rect).copy()
   return rot_image

我做错了什么吗?

最佳答案

尝试使用 pygame.transform.rotozoom标度为 1。 它表示已过滤,我认为这意味着 AA。

关于python - 图像在 Pygame 中旋转,同时保持平滑的边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13272023/

相关文章:

iphone - 带动画的电子邮件图片

python - 将多张图像连接成一张

javascript - 引用数组中的对象时遇到问题

python - 在规定时间内完成画圆

python - Flask 在虚拟环境中不起作用

python - 在 python 脚本之间传递变量

python - PhraseMatcher SpaCy 属性错误 : 'spacy.matcher.phrasematcher.PhraseMatcher' object attribute 'add' is read-only

python - 废弃发电机持有的资源会怎样?

python - 错误: Module 'pygame' has no 'init' member

python - pygame:游戏开始时球的随机方向