Tuesday, February 15, 2011

Long Time No See - WriteableBitmapEx

I actually wanted to release the feature complete version 1.0 of the WriteableBitmapEx library after the previous release, but I've been very busy with other projects during the last year. That's why I decided to release version today. It contains many fixes, but also adds some features (see below). This version finally provides an official Windows Phone binary build, although the Windows Phone project was already available shortly after the first CTP was released. The zipped binaries can be downloaded from here. Please note that this package only contains the WriteableBitmapEx binaries for Silverlight and Windows Phone. All the samples can be found in the source code repository.

There's now also an unmaintained WPF branch of the WriteableBitmapEx library in the source code repository. It was contributed by Szymon Kobalczyk.
One might ask why it's not maintained. I started a poll and it seems that only 7 out of 16 need a WPF version of WriteableBitmapEx. The code is also quite bloated due to conditional compilation flags, which makes it harder to maintain in the future. That's why I decided not to integrate the WPF version. I just don't have enough time to maintain a hardly used version. I would rather point WPF users to Jeremiah Morrill's new project called DirectCanvas. It's in an early stage, but he's a great guy and working hard on it. I'm sure we'll see a great, GPU accelerated 2D drawing library for WPF in the future.

Feature list version
  • Fixed many bugs.
  • Added the Rotate method which rotates the bitmap in 90° steps clockwise and returns a new rotated WriteableBitmap.
  • Added a Flip method with support for FlipMode.Vertical and FlipMode.Horizontal.
  • Added a new Filter extension file with a convolution method and some kernel templates (Gaussian, Sharpen).
  • Added the GetBrightness method, which returns the brightness / luminance of the pixel at the x, y coordinate as byte.
  • Added the ColorKeying BlendMode.
  • Added boundary checks to the Crop() function to avoid OutOfRangeExceptions if the passed parameters are outside the boundaries of the original bitmap.
  • Optimized the DrawLine algorithm.
  • Optimized the Resize algorithms (NearestNeighbor is now 10x faster).
  • Optimized the Clear(Color) method.

Community FTW!
Thanks to the community for constantly reporting bugs and suggesting new features. You rock! That's why I love open source software.


  1. Hi - I am working on some project for WP7, where I have loaded large image (resolution 5000x5000 and bigger) in data stream and I need divide this large image into smaller pieces from that stream. Is there any library which I could use? Or can you prompt me how to do that? Thanks a lot

  2. 5000 x 5000 ARGB pixels ~ 95 MB uncompressed, which alone is over the 90MB memory limit on WP7, even without the app mem footprint.

    You might have to implement your own JPEG reader. this reader needs to split the image when you're reading the stream. Checkout FJCore for Silverlight. Throw out the encoder code and you can use it on WP7. Then hook up your custom reader / split functionality.
    Or just split the images before you load them in your app. If you're using a web server, do it there.

  3. I am loading images from phone media library. Image is loaded into data stream which I need to work with - split it into smaller JPEGs. I think FJCore won´t help me... Or am I missing something?

  4. Please read my comment carefully, FJCore is an open source JPEG library. You can get the code and modify it that the JPEG stream is split into multiple smaller parts while the JPEG is decoded. You can't decode the whole JPEG at once, it's just too large in memory.