如何在新位图上使用 SetPixel?
How do i use SetPixel on a new Bitmap?
代码:
Bitmap newbmp = new Bitmap(512, 512);
foreach (Point s in CommonList)
{
w.WriteLine("The following points are the same" + s);
newbmp.SetPixel(s.X, s.Y, Color.Red);
}
w.Close();
newbmp.Save(@"c:\newbmp\newbmp.bmp", ImageFormat.Bmp);
newbmp.Dispose();
当它尝试 Save
新的 bmp 时,我遇到了异常:
newbmp.Save(@"c:\newbmp\newbmp.bmp", ImageFormat.Bmp);
例外情况是:
ExternalException: A generic error occurred in GDI+
一般来说,当您遇到此类保存错误时,您必须确保您要保存的路径存在,并且您有必要的权限来执行您的保存。
代码:
Bitmap newbmp = new Bitmap(512, 512);
foreach (Point s in CommonList)
{
w.WriteLine("The following points are the same" + s);
newbmp.SetPixel(s.X, s.Y, Color.Red);
}
w.Close();
newbmp.Save(@"c:\newbmp\newbmp.bmp", ImageFormat.Bmp);
newbmp.Dispose();
当它尝试 Save
新的 bmp 时,我遇到了异常:
newbmp.Save(@"c:\newbmp\newbmp.bmp", ImageFormat.Bmp);
例外情况是:
ExternalException: A generic error occurred in GDI+
一般来说,当您遇到此类保存错误时,您必须确保您要保存的路径存在,并且您有必要的权限来执行您的保存。