Bitmap love

  • Thread starter Thread starter Joshua Moore
  • Start date Start date
J

Joshua Moore

I have two issues before we release. First, the big one. Double Buffering,
part of .NET Framework is not in .netCF. So I set up a panel with what
needs to be double buffered, then created another panel off screen, so it
would draw faster, then wanted to quote-unquote set them equal to each other
(or draw the panel off screen, then move it to correct location, without
flashing).

Second, I created a large bitmap for a background, but can't use it as
makeBackground (or whatever it's called) won't work.

I can live without a gradient background, but the double-buffering NEEDS to
happen. I would greatly appreciate anyone's help copying all the
data/graphics from one panel to another quickly to avoid the flashing.

In need,
Joshua Moore
 
Not sure what you're using a Panel for. Double-buffering entails simply
using an offscreen Bitmap to draw into, and after rendering everthing to
that Bitmap, blitting its contents to the on-screen area using a
Graphic.DrawImage call.

I suppose you could override the OnPaint of the off-screen panel, grab the
contents into a Bitmap and then in the OnPaint of the on-screen Panel, blit
it in - but I'm not sure how it will improve things.

A background bitmap can be done pretty easily by overriding the Form's
OnPaint and painting it in manually.

Gradient fill can be achieved using Alex's suggestions here:

http://blog.opennetcf.org/ayakhnin/PermaLink.aspx/3e62434f-6d1d-4e86-9d74-a68bf83ab0cf

-Chris
 
Hi Joshua,
I have two issues before we release. First, the big one. Double Buffering,
part of .NET Framework is not in .netCF.

Mmm, double buffering is a technique where you perform all your drawing
techniques on an offscreen bitmap, then, when all the drawing operations
are done, copy the bitmap in its entirety to the screen. If I'm not
mistaken, the PictureButton example on the www.gotdotnet.com .NET CF
Quickstart section uses this technique, so have a look there.

Also, in order to prevent flickering, try overriding the
OnPaintBackground method with a completely empty method. Completely
empty means also NOT calling the OnPaintBackground method of the superclass.


Regards,

Elisa
 
What is the best way to take an image of the panel (and all the objects
inside)? I know I can use Graphics.DrawImage to "paste it".

Thanks,
 
i'm not sure that you can draw all controls to a bitmap... it would be
interesting though

So, if you have a lot of controls that are flickering when being refreshed
then you might have a problem.

For a simple application i had just ONE Label that needs to be flickerfree.
I have decided to forget the Label and made it with a bitmap. I draw the
text to that bitmap (offscreen) and then paint the bitmap into a picturebox
(that simulates my label)

that works and of course if i need that more often i would make a little
control of it.
But when you need edit-controls, listboxes etc. then it would be a hard job
to do all the drawings by yourself :(

Boris
 
Back
Top