SetSource slow

Jan 6, 2011 at 1:56 PM
Hi all,

First of all I want to say that I like your Lib and it looks very promising to me. But...
I'm facing some performance problems using the ExtendedImage (JpgDecoder)!

I have a large JPG file (~2Mb) and in the first place I want to show (and later manupilate) it.

When I set the image source (default Silverlight Image control) it works quite fast!
 Image image = new Image()
image.Source = New BitmapImage(new Uri("mylargeimage.jpg", UriKind.Relative))
But when I want to set the Uri of the ExtendedImage of the ImageTools lib, It's more then ten(!) times slower:
ExtendedImage img= new ExtendedImage();
img.UriSource = new Uri("mylargeimage.jpg", UriKind.Relative);

What am I doing wrong here?


Jan 6, 2011 at 2:03 PM
You make nothing wrong.

The problem is that loading images in silverlight is done using non
managed libraries, probably written in C or C++ and heavily optimized.
This kind of algorithmis have a enormous overhead with managed code and
many options to optimize are not available in silverlight (e.g. unsafe
code areas).

When it is performance critical for you I would recommend to use a
normal image and later convert this image a to a extendimage using the
ToImage extension method.
Jan 6, 2011 at 2:29 PM
Edited Jan 6, 2011 at 2:32 PM

Okay, thank for the reply. I'll see what I can fix.

When will this lib be adopted by the Silverlight development team, so they can implement their fast and ugly unsafe code? :)

Jan 6, 2011 at 2:37 PM
Hehe, dont know. Ask them :D