Unsafe kernel32-mapped memory Bitmap WPF

Okay, its vacation time so I thought I’d take time from vacation (and from reading news about the terror attacks in Oslo that happened a few miles from here) to do a little post.

This time is an unsafe kernel32 memory mapped bitmap image I’m constantly improving upon. I do a lot of DSP-related stuff and the best way to debug it is to make pretty pictures. Therefore much of the time I work with the FFT data in memory. To achieve speed I allocate memory using kernel23, and I use unsafe pointers to work on it. An added bonus is that it uses InteropBitmap so the picture can be directly used in WPF, great for MVVM.

Here is the current source – under constant development, but may be useful for some.

Notice ImageUIntPtr, ImageIntPtr and ImageBytePtr. In some cases I also use Double or Float pointers, but then its not useful for displaying the picture – only useful as fast memory.

The this-property shows an example of how to access the data.

 

1 thought on “Unsafe kernel32-mapped memory Bitmap WPF”

  1. Hey! I just want to thanks you for posting your solution. My project requires a quite similar approach, and while I mostly did things the same way, your solution is much more sophisticated. So thanks, it’s really useful 🙂

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Tedds blog

Subscribe now to keep reading and get access to the full archive.

Continue reading