سؤال

Im trying to load a file of type .ICO from web and use it as an image in my windows phone. But I get an error when trying to set the source of the BitmapImage. Here is my code:

WebClient client = new WebClient(); 
client.OpenReadCompleted += (s, e) => { 
    if (e.Cancelled) return; 
    if (null != e.Error) throw e.Error; 

    BitmapImage image = new BitmapImage(); 
    image.SetSource(e.Result); 
    this.Favicon = image; 
};

client.OpenReadAsync(new Uri(@"http://mysite/myimage.ico", UriKind.RelativeOrAbsolute));

Does BitmapImage support "ico" files? how to convert an "ico" to a supported BitmapImage file.

THe solution must work on Windows Phone 7.

Tks

هل كانت مفيدة؟

المحلول

The only formats supported by BitmapImage seem to be PNG and JPG.

Not completely stated here, but implied by the comments: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage(VS.95).aspx

A silverlight implementation of .ico handling is here: http://blogs.msdn.com/b/jstegman/archive/2009/09/13/silverlight-ico-icon-decoder-parser.aspx

You might have to modify it to be compatible with the version of silverlight on Windows Phone 7.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top