# Thursday, August 07, 2008
Thursday, August 07, 2008 1:45:47 PM (Pacific Standard Time, UTC-08:00) ( c# | graphics | silverlight )

One of the first issues I've found in Silverlight is it's incapability of handling Gif images, being limited basically to jpeg and png. In most situations this isn't a problem (simply fire up Paint.NET and save the image with a different format), but in cases where the image is being downloaded dynamically (maybe from a weather service server, or similar scenarios) this won't cut it.

I recently found myself in this situation, so I had to write the following code to transform the image:

var sImage = new MemoryStream(imagePath); 
var localImage = Image.FromStream(sImage); 
localImage.Save(newImagePath, 
     System.Drawing.Imaging.ImageFormat.Jpeg); 
sImage.Close(); 

This code should also work to transform the image to every other format included in the System.Drawing.Imaging.ImageFormat class.

The code wasn't implemented on the Silverlight application, but on the webservice feeding it the information. I did it this way to have way more freedom (since the webservice was developed in ASP.NET, it had access to the full .NET framework), and to reduce the work done in the Silverlight app (this format transformation has to be done once everytime the image refreshes, instead of everytime the Silverlight app runs).

Comments are closed.

Your Host

Your host, Ramiro Berrelleza

Ramiro Berrelleza on Twitter del.icio.us Send mail to the author(s)

Tags

animation (2) backup (1) c# (4) graphics (1) office (1) outlook (1) quicktips (1) robocopy (1) silverlight (3)

Archive

Blogroll

Feed

RSS 2.0