Monday, December 7, 2009

WriteableBitmapEx - WriteableBitmap extensions now on CodePlex

I finally kept my promise and put the WriteableBitmap extensions up on CodePlex. This step was long overdue, but when the Silverlight 4 beta was released I couldn't resist and had to play with the new webcam API first (though I'm not finished yet).

The WriteableBitmapEx library project description:
The WriteableBitmapEx library is a collection of extension methods for Silverlight's WriteableBitmap. The WriteableBitmap class that was added in Silverlight 3, allows the direct manipulation of a bitmap and could be used to generate fast procedural images by drawing directly to a bitmap. The WriteableBitmap API is very minimalistic and there's only the raw Pixels array for such operations. The WriteableBitmapEx library tries to compensate that with extensions methods that are easy to use like built in methods. The library extends the WriteableBitmap class with elementary and fast (2D drawing) functionality, supporting common shapes like point, line, ellipse, polyline, quad, rectangle, triangle. Conversion methods and functions to combine WriteableBitmaps (Blitting) are part of it too.
The WriteableBitmapEx library has its origin in several blog posts:
Additional work
I recreated the whole Visual Studio 2008 solutions, changed the namespaces, headers, added comments and cleaned up the code base and samples. I also grouped the extension methods into different CS files with a partial class. It is now possible to include just a few methods by using the specific source CS files directly or all extension methods through the built library assembly.

The WriteableBitmapEx library is released as open source under the Microsoft Public License (Ms-PL) license. The Ms-PL license allows the use of the library without affecting the license of the user, thus making it also easily usable for commercial projects. On the other hand the weak copyleft characteristic ensures that changes on the source have to be committed back and that the library or parts of it always be free and never become closed source.

Touch it, Buy it, Use it, Break it, Fix it, Trash it, Change it, (Mail) - Upgrade it, ...
The WriteableBitmapEx CodePlex project site lives here. You might also want to see the Issue Tracker for a list of features that will be added in the future or to add your own. If you have any comments, questions, suggestions or want to see your name in the Credits list, don't hesitate and write a comment, use the Issue Tracker on the CodePlex site or contact me via any other media.
Have fun and let me know it if you do some cool stuff with it.


  1. Thank you very much for your time and effort into making this available to us.

    I'm using an older version of your code in my codeplex project to show off Audio visualisation and I'll soon be updating to use your CodePlex version.

    thanx again.

  2. oh, YES!!! Thanks for publishing it there...very nice! :) That's the beginning of a nice framework WriteableBitmaps :)

  3. Thanks I really appreciate it!

    Your library is cool. I had a Silverlight FFT control on my ideas list. I just removed it. :) Keep up the good stuff.

    I'll do my best. Again, thanks for your contribution!

  4. Hi Glum,

    the WriteableBitmapEx library is targeted for Silverlight, not WPF. But it should not be hard to recompile it for WPF.

  5. In my work I need to make screenshot from my silverlight app. I can do it with WriteableBitmap class but... This class doesn't work when I try to make screenshot from StackPanel and some another panels.
    Can I do it with WriteableBitmapEx class?

  6. The WriteableBitmapEx library is a collection of extension methods for the WriteableBitmap class. It's not a new class.
    A screenshot of a StackPanel should work. Try this:

    var wb = new WriteableBitmap(myStackPanel, null);

    If not, you can put the StackPanel in another Grid and make a screenshot of this.