I've been using picturebox's for too long and sometimes they lag too much. I've been trying to use the draw a bitmap method instead but I'm not getting it to work. How can I draw a gif that I stored in my application resources and draw on a form. Thanks guys!!
Asked
Active
Viewed 372 times
-2
-
possible duplicate: https://stackoverflow.com/questions/29236265/vb-net-animated-gif-to-bitmap-while-retaining-anim – jazb Nov 17 '18 at 01:43
-
ah i see but what exactly do you mean `directly` - the form is a `container` – jazb Nov 17 '18 at 01:46
-
PictureBox does little to optimize the painting of an image. Well, nothing. If you want it fast then it is very important to resize the image so it is exactly as large as you want to paint it, so it doesn't have to be resized at painting time. And to use the 32bppPArgb pixel format so it is exact match with the video adapter format and the pixels don't have to be converted. The disadvantage is the extra storage required for the converted image, why PictureBox doesn't do this. A speed-up of x100 is possible for large images. Google "c# ImageAnimator" to find code to handle a .gif – Hans Passant Nov 17 '18 at 08:25
-
_Doesn't work_ is not a helpful problem description! - Show your code! Also: Any animation by default is lost when you do a DrawImage. – TaW Nov 17 '18 at 08:31
-
You can do a lot of drawing using the Canvas, including combining image files, adding shapes etc. Here is just one example: https://stackoverflow.com/questions/6008895/drawing-things-on-a-canvas – Wayne Phipps Nov 17 '18 at 11:25
1 Answers
-1
Setting a gif to the form background will not work correctly and will display frozen or not be animated. You can set the form DoubleBuffer "true" to make the picture boxes load a bit faster.
private void Form1_Load(object sender, EventArgs e)
{
this.DoubleBuffered = true;
}
or set it "true" in the form properties.

Joseph
- 11
- 4