使用Cairo旋转图片
Tofloor
poster avatar
lovesnow
deepin
2012-07-09 11:25
Author
找个好久, 做个记录  8-)
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import cairo
  4. import math
  5. surface = cairo.ImageSurface.create_from_png("touxiang.png")
  6. w = surface.get_width()
  7. h = surface.get_height()
  8. surface2 = cairo.ImageSurface(cairo.FORMAT_ARGB32, h, w)
  9. cr = cairo.Context(surface2)
  10. cr.translate(w * 0.5, h * 0.5)
  11. cr.rotate(math.pi * 2 / 3)
  12. cr.translate(-w * 0.5, -h * 0.5)
  13. cr.set_source_surface(surface, 0, 0)
  14. cr.set_operator(cairo.OPERATOR_SOURCE)
  15. cr.paint()
  16. surface2.write_to_png("result.png")
Copy the Code
Reply Favorite View the author
All Replies
tuhaihe
deepin
2012-07-10 18:04
#1
可以将该方法记录到 KMS。
Reply View the author
New Thread

Popular Ranking

Change

Popular Events

More
国际排名
WHLUG