WPF Official Image Interop

Sunday, October 14, 2007

As I wrote my few last posts about how to access the BitmapSource WIC image pixels, I have found a post in the MSDN forum, which exposes a static class called Imaging. This amazing class which somehow was very hard to find, can do a great work with image-interop. Looking inside the MSDN for the Imaging class, I found the following methods: CreateBitmapSourceFromHBitmap CreateBitmapSourceFromHIcon CreateBitmapSourceFromMemorySection The CreateBitmapSourceFromMemorySection is the best match for creating a BitmapSource from a memory section. Looking further inside the updated MSDN it said that "CreateBitmapSourceFromMemorySection - Returns a managed BitmapSource, based on the provided unmanaged memory location". When I tried...

WPF Image Processing Under the Hood

Monday, October 1, 2007

In the last two posts I have showed how to create a BitmapSource image and access its underlying WIC image, for manipulating its pixels. In this post I will explain how does the WICBitmap* works. Download the code from here. Looking inside the BitmapSource class using Reflector, it figures out that it encapsulates a WIC image (_wicSource). The WICBitmap class uses reflection to retrieve this private field: public WICBitmap(BitmapSource source) { Type bitmapSource = typeof(BitmapSource); ...

WPF Raw Video

In my last post I showed how to access the WPF's BitmapSource underlying WIC image, and I promised to explain my code, and also to post an Image stream (Video) code based on my solution. In this post I will quickly talk about the unique CompositionTarget class, and I will show how to render a Raw Video using its Rendered event. Download the code from here (FYI - I refractor the code from the last post and fixed several bugs). I will start by reminding one of the disadvantages of my WICBitmap solution: "Sometimes the Lock/Copy fail. I think that it because...

WPF Image Processing

Friday, September 21, 2007

With the release of Windows Vista and WPF, Microsoft has also released the WIC: "an extensible framework for working with images and image metadata. WIC makes it possible for independent software vendors (ISVs) and independent hardware vendors (IHVs) to develop their own image codecs and get the same platform support as standard image formats (for example, TIFF, JPEG, PNG, GIF, BMP, and WMPhoto)" (MSDN). Unsurprisingly, WPF uses WIC in its core (for example, BitmapSource). Unfortunately, the WPF team chooses to keep the WIC low level API internally, in such a way that there isn't a simple solution for dealing...