Posted By: cosminb | Mar 26th, 2006 @ 2:25 AM
page 1 of 1
Comments: 7 | Views: 7591
Hello C9ers,

I'm having some trouble figuring out how to do this: I've developed a camera library in C++/CLI which I use further in C# apps. After making it accessible to Windows Forms and Direct3D, I want to give Avalon/WPF a try, but this is where I got a bit stuck (lack of proper information). As you can see from the thread's title, I want to achieve
the same functionality that currently is given by MediaElement/MediaPlayer. I want to be able to output my webcam preview video to any Visual element in WPF. How do I do that? Do I need to subclass MediaElement? Or MediaPlayer? Or something else. And how do I customize it? I hope someone has an answer to this really soon, I'm
betting my final year project on this.

Thanks in advance,

Cosmin.

P.S. Also, I want to know if C++/CLI can be used to subclass the controls, or it has to be done in C#.

I've tried several places to get this info, noone seems to care... I hope C9 will.
footballism
footballism
Another Paradigm Shift!
    As I know from your statement, you can use your C++/CLI library in Windows Forms application, then you can leverage upon crossbow technology to host WPF controls(MediaElement, or MediaPlayer) in your Windows Forms Applications.
    Crossbow is a peice of interoperating technology between Windows Forms and WPF, you can get more info from this blog.
    Hopefully this helps.

Hi. This will be very useful. Any chance of a sample when you get it working??? thanks
GRiNSER
GRiNSER
GRiNSER puts a smile on your face :)
why don't you try to put every image you get from the webcam into the Image object as a BitmapImage - i think wpf will be fast enough for this Wink
there are libs out in the web which can find every webcam on your pc and send picture by picture from the cam to your app so that shouldn't be that difficult...
Hi i think i may be able to do what you have suggested here. ONly problem im having is converting between a system.drawing.image to a system.windows.controls.image. cant find anything on web about it.

can you help??

thanks

sash

footballism
footballism
Another Paradigm Shift!
sashah wrote:

    ONly problem im having is converting between a system.drawing.image to a system.windows.controls.image. cant find anything on web about it.

the following code snippet can do the trick:
System.Drawing.Bitmap GdiBitmap = new System.Drawing.Bitmap(@"c:\temp\sample.jpg");
                        IntPtr hBitmap = bitmap.GetHbitmap();
                        System.Windows.Media.BitmapSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmapbitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        System.Windows.Controls.Image WpfImage = new System.Windows.Controls.Image();
                        WpfImage.Source = WpfBitmap;

Sheva
page 1 of 1
Comments: 7 | Views: 7591
Microsoft Communities