D3DImage: display bitmap from byte array

1.6k Views Asked by At

I have raw bitmap data (pixel colors, 32 bit) in an array. Is there a simple way to display such a "sprite" on a D3DImage? Preferably without use of thirdparty libs (such as SharpDX).

Background: I have raw bitmap frames coming from unmanaged DLL and I need to display them with high framerate/low CPU usage in WPF. So far I've tried WriteableBitmap and InteropBitmap, but they are too slow (I get ~110 fps on maximized window (1680x1050 display), Core i5; and this is just a simple test with filling the memory. I believe that modern computers should do this much faster without using 100% CPU core time). I'm also looking at VideoRendererElement (Displaying live video from a raw uncompressed byte source in C#: WPF vs. Win forms), but this is a bit overcomplicated (involves unmanaged dlls, regsvr32 registration, etc).

As I see from D3DImage samples, it achieves good framerates without stressing the CPU. I wonder if it is possible to use it for bitmap display.

UPD: I've found this: http://www.codeproject.com/Articles/113991/Using-Direct2D-with-WPF

Which is basically what I was looking for. I've plugged it into my project, and it is on par with InteropBitmap, even a little bit slower. Looks like memory performance is a bottleneck in my case. In both cases most time is spent on copying bitmap (I use unmanaged memcpy).

0

There are 0 best solutions below