Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
使用Cairo旋转图片
社区开发
2092
views ·
1
replies ·
To
floor
Go
lovesnow
deepin
2012-07-09 11:25
Author
找个好久, 做个记录 8-)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cairo
import math
surface = cairo.ImageSurface.create_from_png("touxiang.png")
w = surface.get_width()
h = surface.get_height()
surface2 = cairo.ImageSurface(cairo.FORMAT_ARGB32, h, w)
cr = cairo.Context(surface2)
cr.translate(w * 0.5, h * 0.5)
cr.rotate(math.pi * 2 / 3)
cr.translate(-w * 0.5, -h * 0.5)
cr.set_source_surface(surface, 0, 0)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
surface2.write_to_png("result.png")
Copy the Code
Reply
Like 0
Favorite
View the author
All Replies
tuhaihe
deepin
2012-07-10 18:04
#1
可以将该方法记录到 KMS。
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
Wifi plugin crash
Popular Events
More