【发布时间】:2016-04-08 07:53:08
【问题描述】:
我无法理解如何使用 pyCairo 简单地旋转图像...
这是我所做的,基于this example:
image_surface = cairo.ImageSurface.create_from_png(image_path)
width = image_surface.get_width()
height = image_surface.get_height()
context = cairo.Context(cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height))
context.translate(width*0.5, height*0.5)
context.rotate(45.0*math.pi/180.0)
context.scale(1.0, 1.0)
context.translate(-width*0.5, -height*0.5)
context.set_source_surface(image_surface, 0, 0)
context.paint()
image_surface.write_to_png(output_path)
输出图像与初始图像相同。 我错过了什么?
【问题讨论】: