我正在做这个油漆应用程序.这很简单.它由一个我将绘制的面板组成,然后我将保存为JPG或BMP或PNG文件.
我的应用程序工作完美,但我面临的问题是,当我保存输出时,不是面板上绘制的,它的黑色图像不仅仅是黑色.
我的所有工作都被保存为
Thepic = new Bitmap(panel1.ClientRectangle.Width, this.ClientRectangle.Height);
Run Code Online (Sandbox Code Playgroud)
在我的鼠标(向下,向上的东西)上
snapshot = (Bitmap)tempDraw.Clone();
Run Code Online (Sandbox Code Playgroud)
并且它保存了正常的工作但是再次声明是黑色图像不是面板包含的内容.
Tom*_*ell 12
我认为问题可能是你正在使用"克隆"方法.
尝试" DrawToBitmap " - 这在过去对我有用.
这是一个从名为"plotPrinter"的控件中保存位图的示例:
int width = plotPrinter.Size.Width;
int height = plotPrinter.Size.Height;
Bitmap bm = new Bitmap(width, height);
plotPrinter.DrawToBitmap(bm, new Rectangle(0, 0, width, height));
bm.Save(@"D:\TestDrawToBitmap.bmp", ImageFormat.Bmp);
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)Be aware of saving directly to the C directly as this is not permitted with newer versions of window, try using SaveFileDialog.
SaveFileDialog sf = new SaveFileDialog();
sf.Filter = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif|JPEG Image (.jpeg)|*.jpeg|Png Image (.png)|*.png|Tiff Image (.tiff)|*.tiff|Wmf Image (.wmf)|*.wmf";
sf.ShowDialog();
var path = sf.FileName;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22211 次 |
| 最近记录: |