1

my previous question with source code is here: How to use gif animated image in WP 7

I am using http://imagetools.codeplex.com/ in my animated gif I have 24 frames, but it decodes only some first frames, so I see repetition animation of some(maybe two) frames again and again

Community
  • 1
  • 1
revolutionkpi
  • 2,632
  • 10
  • 45
  • 84
  • 1
    Just out of curiosity, why use an animated .gif with silverlight? Especially on a phone? Why not just create your image animation with a Storyboard in xaml and add it via a ContentControl or something? – Chris W. Mar 12 '12 at 18:29
  • @Chris W.: revolutionkpi's animated GIF is a detailed rotating globe of the world. Probably way too inefficient for practical use, but an interesting problem to solve all the same. – iCollect.it Ltd Mar 13 '12 at 08:19

1 Answers1

1

For some gif-files this decoder work, for some other - don't.

I downloaded source code of that project and found the code which doesn't work correctly. It is situated in the ImageTools.IO.Gif\GifDecoder.cs file, the Decode method:

int nextFlag = stream.ReadByte();
while (nextFlag != 0)
{
    //...
}

But this gif contains the 0 byte right in the middle, so that the decoder stops where it shouldn't. The solution is to change this flag to -1 so that we are sure that the gif image will be read to the end:

int nextFlag = stream.ReadByte();
while (nextFlag != -1)
{
}

So you need either to recompile this library or to include the ImageTools.IO.Gif project in the form of source code rather than in the form of dll.

You can download the sample project here: http://dl.dropbox.com/u/8047386/StackOverflow/TestGif.zip

But I'm not sure that one can rely on this fix. Anyway I opened the issue at codeplex.

vortexwolf
  • 13,967
  • 2
  • 54
  • 72