[Mono-winforms-list] Copy rather than drawing an image to a graphics object?

cs_eps christian.schmid at eps.ch
Wed Jan 5 07:37:26 EST 2011


I use the classic double buffering pattern for drawing a user control
avoiding flicker
1) override the OnPaintBackground with an empty body
2) in the OnPaint override draw all stuff (including the background) in a
buffer bitmap and draw it at the end with the graphics object in the event
args with eventArgs.Graphics.DrawImage.

This works fine if the control has a solid color, but my control has a
transparent background. It is kind of a window on a video frame with some
overlay graphics.

The problem is that DrawImage paints the new image on the old image because
of the transparent backgound. The only way to avoid this, is to call
eventArgs.Graphics.Clear(Color.Transparent) before calling the DrawImage
(could be done in OnDrawBackground)... but this flickers!

So I need to copy rather than draw the image. Any idea on how to achieve
View this message in context: http://mono.1490590.n4.nabble.com/Copy-rather-than-drawing-an-image-to-a-graphics-object-tp3175423p3175423.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.

More information about the Mono-winforms-list mailing list