I created a simple animated GIF using Adobe Flash CS3, the GIF contains 200 frames (1280x786). When I load it to be displayed in a C# WPF application, the program gets an OutofMemoryException on the following code
private void set_gif_Image(String path)
{
if (File.Exists(path))
{
var bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.UriSource = new Uri(path);
bitmapimage.EndInit();
ImageBehavior.SetAnimatedSource(img_preview, bitmapimage);//Exception Here
}
else
{
var bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.UriSource = new Uri("C:\\testing_files\\ERROR.gif");
bitmapimage.EndInit();
ImageBehavior.SetAnimatedSource(img_preview, bitmapimage);
}
But if I load a 20 frame GIF for example, the program loads fine. Notice the following Situations:
- 1280x768 with 200 frames: Exception
- 550x400 with 200 frames: Loads fine
- 1280x768 with 50 frames: Loads fine
Where is the problem? how to get such large animated GIF loaded without an exception?