.net - Convert Bitmap to BitmapSource -


i have problem converting bitmap bitmapsource, write http://www.codeproject.com/kb/wpf/bitmaptobitmapsource.aspx?msg=3590727 , exceptions: first chance exception of type 'system.invalidoperationexception' occurred in windowsbase.dll :/ must convert bitmap bitmapsource, beacouse use aforge.net caputer image webcam. know why exception ? ( works winforms ) or mayby know library looking similarity aforge can use wpf?

my code:

private void newframehandler(bitmap bitmap) {     bitmapsource bitsrc = null;     var hbitmap = bitmap.gethbitmap();       bitsrc = system.windows.interop.imaging.createbitmapsourcefromhbitmap(          hbitmap,          intptr.zero, int32rect.empty,             system.windows.media.imaging.bitmapsizeoptions.fromemptyoptions());      image1.source = bitsrc; } 

the code looks me, though need use pinvoke method deleteobject release memory used hbitmap.

the reason can think of failing, there wrong bitmap being converted.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -