位图中的一般异常 [英] Generic exception in Bitmap
本文介绍了位图中的一般异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
执行此代码集时,我在GDI +中遇到一般错误.
请帮忙..
我正在使用此代码,
I am getting an Generic Error in GDI+ while executing this code set.
Please Help..
I am using this code,
private void btn_Send_Click(object sender, EventArgs e)
{
Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
bitmap.Save("C://test.jpg",ImageFormat.Jpeg);
}
}
推荐答案
这是一个权限问题:Win7(和Vista IIRC)不允许一般用户对系统根文件夹进行写权限磁盘.
将图像文件移动到可以写入的子目录,就可以了:
It''s a permissions problem: Win7 (and Vista IIRC) will not allow a general user write permission to the root folder of the system disk.
Move your image file to a subdirectory that you can write in, and you will be fine:
bitmap.Save("C:\\Temp\\test.jpg",ImageFormat.Jpeg);
这篇关于位图中的一般异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文