星空网 > 软件开发 > ASP.net

WPF bitmap转bitmapimage 使用 CreateBitmapSourceFromHBitmap内存泄漏

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

然后新建一个类

 static class Class1  {   [System.Runtime.InteropServices.DllImport("gdi32.dll")]   public static extern bool DeleteObject(IntPtr o);  }

然后每次在转化以后 

 Class1.DeleteObject(f);

一下就好了

内存就不会**了 





原标题:WPF bitmap转bitmapimage 使用 CreateBitmapSourceFromHBitmap内存泄漏

关键词:wpf

wpf
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

非接触式支付:https://www.goluckyvip.com/tag/5991.html
纳粹德国的标志:https://www.goluckyvip.com/tag/59915.html
二战德国的标志:https://www.goluckyvip.com/tag/59920.html
德国大众车标:https://www.goluckyvip.com/tag/59921.html
纳粹德国标志:https://www.goluckyvip.com/tag/59925.html
Clark:https://www.goluckyvip.com/tag/5993.html
咸阳机场到临潼景点 西安咸阳机场到临潼有多远:https://www.vstour.cn/a/411236.html
合肥有什么约会的地方好玩的地方 合肥哪里适合情侣好玩的地方:https://www.vstour.cn/a/411237.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流