Save to disk ?

Feb 20, 2009 at 2:51 PM
Hi,

First of all, you did a really impressing and extremely technical job !

I already use your projet to display various directshow source in a WPF application but I'd like to know if you can tell me a way to compress and save the stream.

There're some examples of that over the internet but i really don't know how to plug them into your solution.

Thanks in advance.

Regards,
Martin.
May 28, 2009 at 8:35 PM

I have a related question: I need to be able to save the current image to disk.  Is there a way to access the current image?  I cannot find it by looking through the WPF Element's properties/methods.

 

--Thanks

Kyle

Coordinator
May 28, 2009 at 8:38 PM
Try looking at the RenderTargetBitmap class in WPF.  It can render any WPF visual to a bitmap, then you can save to disk.  There are many RTB examples on the internets.

Oct 8, 2009 at 7:15 PM
Edited Oct 8, 2009 at 7:20 PM

The RenderTargetBitmap class works fine if you don't scale your bitmap while showing it.

In my case I need the 'raw' source bitmap.

Therefore I changed the visibility of D3DRenderer.D3DImage to public and used the following function:

 

        public  RenderTargetBitmap GetBitmapOfVideoElement()
        {
            DrawingVisual visual = new DrawingVisual();
            DrawingContext context = visual.RenderOpen();
            int w = videoElement.D3DImage.PixelWidth;
            int h = videoElement.D3DImage.PixelHeight;
            context.DrawImage(videoElement.D3DImage, new Rect(0,0,w,h));
            context.Close();

            RenderTargetBitmap bitmap = new RenderTargetBitmap(w, h, 96, 96, PixelFormats.Default);
            bitmap.Render(visual);

            return bitmap;
        }

 

Is there a better way to get the source picture?