[wxPython-users] Re: Not quite understanding buffered DCs
Robin Dunn
robin at alldunn.com
Thu Dec 28 10:48:16 PST 2006
Jeffrey Barish wrote:
> Robin Dunn wrote:
>> It is all for convenience. That one line in the example replaces about
>> 4 lines it would take to do it without a wx.BufferedPaintDC. In fact,
>> all of the buffered dc classes are entirely for convenience. You can do
>> everything they do yourself with just a bitmap, a MemoryDC and a
>> ClientDC or PaintDC.
>
> Sure, in general it takes all those elements. But in this case, isn't it
> true that we don't need the MemoryDC? The image that we want to draw is
> already whole in self.bitmap, so we should be able to blit it to the
> PaintDC without having to worry about flicker:
>
> dc = wx.PaintDC()
> w, h = self.buffer.GetSize()
> dc.Blit(0, 0, w, h, self.buffer, 0, 0)
No, the 5th parameter of Blit is a DC, not a bitmap. You could do it
with dc.DrawBitmap instead of Blit, but that just creates a MemoryDC
internally on most platforms anyway.
> Also, is it true that the additional overhead associated with
> creating the buffered device context (that is, the overhead associated with
> creating the MemoryDC) is small?
Yes.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list