Not quite understanding buffered DCs

Jeffrey Barish jeff_barish at earthlink.net
Thu Dec 28 11:17:23 PST 2006


> dc = wx.PaintDC()
> w, h = self.buffer.GetSize()
> dc.Blit(0, 0, w, h, self.buffer, 0, 0)

This code fragment is wrong.  I discovered that I could download the source
code for the examples from http://www.manning.com/rappin/, so I ran some
tests.  The correct equivalent to the use of a buffered DC (as in the book)
is:

dc = wx.PaintDC(self)
w, h = self.buffer.GetSize()
dc2 = wx.MemoryDC()
dc2.SelectObject(self.buffer)
dc.Blit(0, 0, w, h, dc2, 0, 0)

The Blit method requires a DC as the source, not a bitmap, so it is
necessary to create a MemoryDC.  Much easier to use the buffered DC.
-- 
Jeffrey Barish





More information about the wxpython-users mailing list