IntPtr f = bmp.GetHbitmap();
img.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(f, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
这里要是多次使用 不及时释放内存就会爆炸~
解决办法:
用windows下的GDI32.DLL类
使用办法:
先引用system.runtime.serialzation类
如果解决方案配置是在Debug下面的话
把gdi32.dll放在bing\debug