winfrom将控件保存为图片

案例:将panelEx2保存为png图片

string chartUrl = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"Chart_d" + velocityId + ".png";
Bitmap bmp = new Bitmap(panelEx2.Width, panelEx2.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
panelEx2.DrawToBitmap(bmp, new Rectangle(0, 0, panelEx2.Width, panelEx2.Height));
bmp.Save(chartUrl, System.Drawing.Imaging.ImageFormat.Png);

 将 Steema.TeeChart.TChart 保存为图片

string chartUrl = @".Chart_d" + velocityId + ".png"; 
tChart1.Export.Image.PNG.Save(chartUrl); //保存为png格式;

....

作者:chenze
出处:https://www.cnblogs.com/chenze-Index/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
如果文中有什么错误,欢迎指出。以免更多的人被误导。
原文地址:https://www.cnblogs.com/chenze-Index/p/15117909.html