WinForms图形问题 [英] WinForms Graphics problem

查看:68
本文介绍了WinForms图形问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了mi Windows Form Application的问题。我正在尝试使用bitmap.Clone()方法克隆位图时使用我的网络摄像头捕获图像并且程序崩溃。所以我得到了这个未处理的错误:该对象正在使用中。尝试捕获并不能完成交易,因为我需要我的picturBox刷新图像,所以问题(对象正在使用中)仍在继续。



崩溃:

位图bitmap2 = bitmap.Clone(new Rectangle(0,0,320,240),PixelFormat.Format24bppRgb)



作为建议,visual studio推荐我:如果我在de GetHdc方法之后使用Graphics对象,我必须调用ReleaseHdc方法。





这里是一张问题照片的链接

http://i43.photobucket.com/albums/e364/kedelvan/Sintiacutetulo.png



我不知道我在哪里使用GetHdc方法,我从来没有在我的代码上明确地调用它。



我必须发布一些我不知道的东西。



我感谢任何帮助。

谢谢

解决方案

insted of 位图bitmap2 = bitmap.Clone( new 矩形( 0 0 320 240 ),PixelFormat.Format24bppRgb)

使用

位图bitmap2 =新位图(位图)



这可以解决问题。


Hi, i got an issue with mi Windows Form Application. Im capturing images with my webcam and the program crashes when im trying to clone a bitmap with the bitmap.Clone() method. So i get this unhandled error: " The object is in use ". A try catch doesn''t do the deal because i need that my picturBox refresh images, so the problem (object is in use)still goes on.

Crashes at:
Bitmap bitmap2 = bitmap.Clone(new Rectangle(0 ,0 ,320, 240), PixelFormat.Format24bppRgb)

As a suggestion, visual studio recommends me that: If i am using a Graphics objects after de GetHdc method, i have to call the ReleaseHdc method.


Here''s a link to a photo of the problem
http://i43.photobucket.com/albums/e364/kedelvan/Sintiacutetulo.png

I dont have a clue of where i use a GetHdc method, i have never explicitly called it on my code.

I have to release something that i dont know.

I appreciate any help.
Thanks

解决方案

insted of

Bitmap bitmap2 = bitmap.Clone(new Rectangle(0 ,0 ,320, 240), PixelFormat.Format24bppRgb)

use

Bitmap bitmap2 = new Bitmap(bitmap)


this should solve the problem.


这篇关于WinForms图形问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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