与PyGame集成
PyGame&ImageSurface
从ImageSurface创建一个pygame.Image:
import pygame
import cairo
width, height = 255, 255
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
buf = surface.get_data()
image = pygame.image.frombuffer(buf, (width, height), "ARGB")