它是安全的呼吁Icon.ToBitmap后处置的图标()? [英] Is it safe to dispose the Icon after calling Icon.ToBitmap()?

查看:263
本文介绍了它是安全的呼吁Icon.ToBitmap后处置的图标()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

呼叫后 System.Drawing.Icon.ToBitmap()以创建一个图像,它是安全丢弃原图标

After calling System.Drawing.Icon.ToBitmap() to create an image, is it safe to dispose the original Icon?

推荐答案

是的。 Icon.ToBitmap绘制图标到一个新的位图对象,因此它是安全的处理之后它

Yes. Icon.ToBitmap draws the Icon to a new Bitmap object so it is safe to dispose it afterwards.

编辑:

纵观图标。在反射器ToBitmap()方法很有趣。我期望这是一个简单的Graphics.DrawImage或Graphics.DrawIcon呼叫,但它是比这更复杂。只要有可能功能会做的图标图像数据的存储副本,而不是,但它会恢复到Graphics.DrawImage或Graphics.DrawIcon电话,如果它不能进行复制。内存复制速度要快得多,这样明显的原因,但是这使得代码更难阅读。


Looking at the Icon.ToBitmap() method in Reflector was interesting. I expected it to be a simple Graphics.DrawImage or Graphics.DrawIcon call but it is more involved than that. As long as it is possible the function will do a memory copy of the icon image data instead, but it will revert to a Graphics.DrawImage or Graphics.DrawIcon call if it cannot perform the copy. The memory copy is much faster so that is obviously the reason, but this makes the code much harder to read.

这篇关于它是安全的呼吁Icon.ToBitmap后处置的图标()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆