How to display a gif image in Windows Phone 7?

I am trying to upload images from facebook. if the user has set the profile image, then the image is jpg, however, if the user has not set it, the image will become a stub in gif format. I know that wp7 does not support displaying gifs (out of the box). is there any way to determine if the final image is gif or not?

For example, I do a BitmapImage as follows:

BitmapImage img = new BitmapImage(new Uri("https://graph.facebook.com/userid1/picture")) 

for this uri, the user has no profile picture. so I get a gif stub image at https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif .

If the user has an image, I request it as follows.

 BitmapImage img = new BitmapImage(new Uri("https://graph.facebook.com/userid2/picture")) 

for the above url, I get a url like this: https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/000000_1621037713_00000000_q.jpg

Then my question is, as soon as I get the BitmapImage object, img, can I determine if it is a JPG or GIF? can i convert it to jpg if it's a gif?

I looked at some related issues, but the API discussed loading the image asynchronously, which I did not want at the moment. In addition, there was poor documentation.

any help is appreciated.

nevermind, I followed these instructions: Show GIF in a WP7 application with Silverlight . The user gave a great walk.

  • what you need to do before doing what this user suggested is to download the source code from codeplex.

  • then you need to download the BitMiracle JPEG library from http://bitmiracle.com/libjpeg/ .

  • Go to the / src / ImageTools directory and open ImageTools.Phone.sln. add the ImageTools.IO.Jpeg.Phone project to the solution.

  • when you create the solution, it will complain that it will not find the BitMiracle JPEG DLL, and give a link to this DLL for the Jpeg project. build again and it should work.

0
source share
1 answer

First upload the image (any) using Httprequest or Webclient, and then convert to jpg or png from gif (if it's gif) as follows.

  GifDecoder gd = new GifDecoder(); ImageTools.ExtendedImage img = new ImageTools.ExtendedImage(); gd.Decode(img, stream); //stream means image stream PngEncoder png = new PngEncoder(); png.Encode(img, isoFileStreamdownload); //isoFileStreamdownload means stream, which is used to save image in image file like(image.png)) 

using ImageTools.dll, ImageTools.IO.Gif.dll, ImageTools.IO.Png.dll (Image Tools)

I think it helps you

+2
source

All Articles