Show Videosignal in .Net WPF/DirectX
I have a videosignal that provides me a buffer with a YCbCR-Signal. I can convert it to RGB by doing some math but I have no idea how to show the video in ,Net WPF. I also tried to use SlimDX and render the stream to a sprite but this is onl开发者_开发百科y an idea and I also don't have a clue how to start.
Thanks for help, Meldur
If you can convert it to RGB, you have Bitmap in your hands. You can lock bitmap and set it's data. When you creating new Bitmap, you can set pixel format (24bpp, 32bpp), so creating Bitmap from video frame shouldn't be problem.
Every time you get new frame, all you need is to update texture in DirectX. Textures in DirectX has various formats and some of them are compatible with bitmap formats, you can even create new texture using Bitmap.
First find some examples how to render texture in DirectX (SlimDX, ManagedDirectX...), then update texture every time new frame comes in. If you don't want to bother with texture locking and updating, you can create new texture every time new frame comes, using this constructor
public Texture(Device, Bitmap, Usage, Pool);
Even if you don't want to bother with DirectX, you can render directly into Canvas in WPF
class MyCanvas : Canvas {
protected override void OnRender (DrawingContext dc) {
BitmapImage img = ...;
dc.DrawImage (img, new Rect (0, 0, img.PixelWidth, img.PixelHeight));
}
}
To get BitmapImage from Bitmap, look here link text
精彩评论