All the codes I've found give me the same result: a bunch of exact looking frames. Meaning: it gives me a list of the first frame, repeated X number of times. The .gif I'm using has 30 frames, so I get 30 times the first frame, instead of the 30 different frames.
public static Image[] GetFramesFromAnimatedGIF(Image IMG)
{
List<Image> IMGs = new List<Image>();
int Length = IMG.GetFrameCount(FrameDimension.Time);
for (int i = 0; i < Length; i++)
{
IMG.SelectActiveFrame(FrameDimension.Time, i);
IMGs.Add(IMG);
}
return IMGs.ToArray();
}
What am I missing? ALL the codes I've looked give the first frame repeated X numbers of times.
This is what is supposed to look (using a webpage). See how each frame is different?
This is what it looks for me after saving every frame inside that array on a folder location (a bunch of equal frames):
P.S.: Yes, it's a .gif the image I'm using.
Update: The problem seems to be when I read the file in the OpenFileDialog, as it works if I pass my .gif by code. So how do I read an animated gif in the OpenFileDialong? Thank you.
GIF cutter (cut to length)You can remove the beginning or end of the GIF, or cut out the middle part. You can either specify the cut duration in seconds or enter the exact frame numbers where you want the GIF to be cut. If you want to cut file dimensions instead of length, you should use our crop tool instead.
IMGs.Add(IMG);
That's the bug, you are adding the same IMG object over and over again. You need to make a deep copy of the frame. That's very easy to do:
IMGs.Add(new Bitmap(IMG));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With