[cairo] When to use cairo_win32_surface_create

Gerdus van Zyl gerdusvanzyl at gmail.com
Sat May 16 00:44:04 PDT 2009


When you want to draw to a windows surface like a window you use
cairo_win32_surface_create. You only need to use an image surface if
you really need/want an image surface. To make it appear you need to
handle the win32 paint event(WM_PAINT).

The following is the code for wm_paint in my python app (C api is similiar):
def OnPaint(self, hWnd, msg, wparam, lparam):
hdc, ps = BeginPaint(hWnd)

_buffer = hdc
surf = cairo.Win32Surface(_buffer)
ctx = cairo.Context(surf)

#the group funcs are for double buffering and are optional
ctx.push_group_with_content(cairo.CONTENT_COLOR)
self.uWindow.event_paint(ctx,[cx,cy,cw,ch])   <- your drawing function here
ctx.pop_group_to_source()
ctx.paint()

surf.finish()

EndPaint(hWnd,ps)

~G


On Sat, May 16, 2009 at 2:25 AM, Andrew S Katz (tb) <akatz712 at gmail.com> wrote:
>
> I am new to cairo. My goal is to use it in a Microsoft Windows
> application which shows curved shapes I generate using mathematical
> formulas. When do I use cairo_win32_surface_create and when do I use
> cairo_image_surface_create? And are there any rules on how to set up or
> not to set up a Window to show the graphics?
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list