gpt4 book ai didi

c# - 在绘画应用程序中保存图像 C#

转载 作者:行者123 更新时间:2023-11-30 13:28:21 25 4
gpt4 key购买 nike

我正在开发一个简单的绘画应用程序。除了保存,我一切正常。我正在面板内进行所有绘画操作。我需要将其保存为图像。如何做到这一点?

最佳答案

使用此代码

Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);//to create bmp of same size as panel
Rectangle rect=new Rectangle(0,0,panel1.Width,panel1.Height); //to set bounds to image
panel1.DrawToBitmap(bmp,rect); // drawing panel1 imgae into bmp of bounds of rect
bmp.Save("C:\\a.png", System.Drawing.Imaging.ImageFormat.Png); //save location and type

关于c# - 在绘画应用程序中保存图像 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6069666/

25 4 0
文章推荐: c# - 如何在发送邮件时捕获特定异常?
文章推荐: javascript - 循环遍历