• 0

[C#] Animated gif and cpu usage


Question

Hi,

I have a problem-my program uses an animated gif and that causes a rise in the CPU usage.Is there a way to minimize the rise of the CPU usage when using animated gifs?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Oh,your'e right :rolleyes: .I'm using c# (I'm a beginner so... :) ) and I'm doing the animation by changing the gif's frames and drawing them(sorry but I don't really know how to explain this) this way:

Gifs.SelectActiveFrame(dimension,i); 
	g.DrawImage(Gifs,x, 1,width, height);

The "i" is the number of the frame which I change each time to make the animation.The problem is that drawing the image each time causes a rise in the CPU usage.Is there any way to reduce it?

Edited by yyy
Link to comment
Share on other sites

  • 0

What's your "Gifs" object, and what's g? :huh: It sounds like you're drawing the frames yourself, instead of using an actual animated gif, which would account for the high CPU usage...

Title edited

Link to comment
Share on other sites

  • 0

Gifs is the animated gif image and g is:

? ? ?private void Panel_Resize(object sender, System.EventArgs e)
 ? ? ? ?{
 ? ? ? ?Graphics g = e.Graphics;
.
.
.

What do you mean by drawing the frames myslef?

I draw each frame of the animated gif.

Link to comment
Share on other sites

  • 0

To accomplish this, the best way (aside from using ImageAnimator) would be to load all of the frames at once, each into its own variable, and then use a PictureBox to cycle through the images. Set the PictureBox's Image property to the image representing the current frame each time it switches.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.