.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

python - Why doesn't list have safe "get" method like dictionary? -

razor - Is this a bug in WebMatrix PageData? -

sql server - Stored procedure -