This project is read-only.

Design Principles

Imagetools follows two design principles:
  1. Modularity: Keep your silverlight application small by only adding the support for different image formats which you really need.
  2. Threading: Imagetools try to use threading when possible. This improves the performance but it is necessary to use events to get information about exception.

Load your first Image

To load your first image you have to register all decoders (which are modules, that are responsible to images with a specific format):

Register Decoders

ImageTools is seperated in different assemblies. Each supported image format has its custom assembly to reduce the size of your application. By default the Image class does not know a image format and always throws an exception and you must register decoders and encoders first before loading files:

At the moment the following file formats are supported in the specified assemblies:
  1. ImageTools.IO.Bmp
  2. ImageTools.IO.Png
  3. ImageTools.IO.Jpeg
  4. ImageTools.IO.Gif

To register a decoder for loading images use the following line of code in your startup code:
using ImageTools.IO;


For example:
using ImageTools.IO;
using ImageTools.IO.Bmp;
using ImageTools.IO.Gif;
using ImageTools.IO.Jpeg;
using ImageTools.IO.Png;


Load the Image

You can load in a very similar way as you would do it when using the image class from the silverlight sdk.

Load an embedded Image

  • Create an Images folder in your silverlight project.
  • Add an image to this folder.
  • Set the build action of this image to Resource in the properties tab.
  • Load the image
ExtendedImage desert = new ExtendedImage();
desert.UriSource = new Uri("/Images/Desert.jpg", UriKind.Relative);

Your image will now be loaded asynchronously. To get a notification when the loading is completed or when loading failed, subscribe the the LoadingFailed and LoadingCompleted event.
public void LoadImage()
   ExtendedImage desert = new ExtendedImage();
   desert.LoadingFailed += desert_LoadingFailed;
   desert.LoadingCompleted += image_LoadingCompleted;
   desert.UriSource = new Uri("/Images/Desert.jpg", UriKind.Relative);

private void desert_LoadingFailed(object sender, UnhandledExceptionEventArgs e)
    // Your image could not be loaded.

private void image_LoadingCompleted(object sender, EventArgs e)
    // The image has been loaded successfully.

Last edited Jan 4, 2012 at 6:30 AM by malignate88, version 9


radgroza Feb 3, 2016 at 1:03 PM 
Ok, so with ImageTools you can registrer decoders, you can load image, but why you didn't say how to _display an image_? So in short how should I use ImageTools to load image and assign it as a Source of Controls.Image? ExtendedImage is not derived from System.Windows.Media.ImageSource, so is there any use of ImageTools?

masterq82 Apr 25, 2012 at 8:44 PM 
I am confused about your license. You are publishing the binary using the Ms-PL but you are including the Silverlight SharpZipLib library which is published using the GPL license (
Aren't both licenses incompatible or did I miss something?

chanyuenpang Feb 11, 2012 at 11:21 AM 
when I create an instance of ExtendedImage, it throws an "MissionMethodExeception".
File or assembly name 'PhoneCodeContractsAssemblies, Version=, Culture=neutral, PublicKeyToken=null', or one of its dependencies, was not found.

However it comes out fine in my old project.
I wondered what may cause this error and how to solve it...

ggshi Dec 16, 2011 at 3:49 AM 
How could I save the Silverlight portion of screenshot as an image? Using WriteableBitmap gives me a security exception always. Your help is very appreciated.

MosquitoD4K Nov 20, 2011 at 4:14 PM 
I think, you could use a ValueConverter

acohen Mar 17, 2011 at 3:36 PM 
Good question. Can this be done in xaml?

hanxianlong Mar 14, 2011 at 4:41 AM 
How could I load an image in am xaml?