GTK2:公开事件,PNG 文件的 blit 部分

GTK2: Expose Event, blit part of a PNG file

我能以某种方式在 GTK2 的公开事件中 blit 一部分 PNG 文件吗?我可以在 Pixbuf 中加载 PNG 并使用 Cairo 将 Pixbuf 用作画笔,但我不知道我怎么只能使用 PNG 的矩形 (1,1,10,10) 作为画笔。有人能指出我正确的方向吗?

cairo_image_surface_create_from_png is a good way to create a Cairo-centric PNG surface. You could then use cairo_surface_create_for_rectangle to restrict the size of the cairo_surface_t. Then you use cairo_set_source_surface 使用从 create_for_rectangle 返回的表面作为源或画笔。