flicker in wxBufferedPaintDC

M

Markus von Ehr

Hi,

I actualize a buffer in an event handler routine:

if BUFFERED:
# If doing buffered drawing, create the buffered DC, giving it
# it a real DC to blit to when done.
cdc = wxClientDC(self)
dc = wxBufferedDC(cdc, self.buffer)

dc.BeginDrawing()
if self.image:
dc.DrawBitmap(self.image.ConvertToBitmap(), 0,0)
dc.EndDrawing()

and paint the buffer in the OnPaint method.

def OnPaint(self, event):
if BUFFERED:
# Create a buffered paint DC. It will create the real
# wxPaintDC and then blit the bitmap to it when dc is
# deleted. Since we don't need to draw anything else
# here that's all there is to it.
dc = wxBufferedPaintDC(self, self.buffer)
else:
dc = wxPaintDC(self)
# since we're not buffering in this case, we have to
# paint the whole window, potentially very time consuming.
self.DoDrawing(dc)


but the window is flickering. The window displays the liveimage of a
connected camera.
How could I get rid of the flickering?

Thanks for any hints,

Markus
 
T

Tom B.

Markus von Ehr said:
Hi,

I actualize a buffer in an event handler routine:

if BUFFERED:
# If doing buffered drawing, create the buffered DC, giving it
# it a real DC to blit to when done.
cdc = wxClientDC(self)
dc = wxBufferedDC(cdc, self.buffer)

dc.BeginDrawing()
if self.image:
dc.DrawBitmap(self.image.ConvertToBitmap(), 0,0)
dc.EndDrawing()

and paint the buffer in the OnPaint method.

def OnPaint(self, event):
if BUFFERED:
# Create a buffered paint DC. It will create the real
# wxPaintDC and then blit the bitmap to it when dc is
# deleted. Since we don't need to draw anything else
# here that's all there is to it.
dc = wxBufferedPaintDC(self, self.buffer)
else:
dc = wxPaintDC(self)
# since we're not buffering in this case, we have to
# paint the whole window, potentially very time consuming.
self.DoDrawing(dc)


but the window is flickering. The window displays the liveimage of a
connected camera.
How could I get rid of the flickering?

Thanks for any hints,

Markus


You could try using a self.PrepareDC(dc),
or perhaps a wx.SafeYeild(),
or perhaps you need the wx.NO_FULL_REPAINT_ON_RESIZE flag set,
or perhaps you just need to speed up execution , try
http://psyco.sourceforge.net/.

hope this helps.
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,218
Latest member
NatishaFin

Latest Threads

Top