Wednesday, 4 May 2011

Problems Using GIF Images In SilverLight

When first getting to grips with Silverlight, I had some problems with images.

I was creating a new Silverlight game for Play-Free-Games.com ("Panda Football" - yet another variant on the same old "Panda's playing football" theme one sees so often), and I was ready to start showing my Panda GIF images on screen.

No matter what I tried, the images were not displayed. I figured I must be specifying the path incorrectly, so I went through a long and tedious process of trying every possible relative or absolute method for defining the image path. I was on the point of tears when I tried displaying another image I happened to have to hand (a picture of a sheep - no further details required). To my intense joy, the image loaded up exactly as expected.

My initial assumption was that SilverLight does not support images of pandas, only farmyard animals. I was about to put this to the test by trying some goat, duck and chicken images when I realised that there was another key difference - my sheep pic was a jpg.

"Surely the problem isn't simply that Silverlight does not support the GIF format", I thought to myself, but not for the first time that day I was so wrong:


So, I converted my GIFs to PNGs and all was well. Cashback!