开发者

Is it possible to create a JPG from a Control?

开发者 https://www.devze.com 2023-03-29 21:40 出处:网络
Lets sa开发者_如何学Cy I have a custom control (child of System.Windows.Forms.UserControl) such as a graph. Is there a way I can take the drawing I did on the control and just export the current graph

Lets sa开发者_如何学Cy I have a custom control (child of System.Windows.Forms.UserControl) such as a graph. Is there a way I can take the drawing I did on the control and just export the current graphical state of the control to a JPG file?


It is possible. Basically you will need to ask the control to render itself to a Bitmap and then save the Bitmap as jpeg

See the documentation of Control.DrawToBitmap() method.

Bitmap bmp = [Control.DrawToBitmap();
            bmp.Save("", System.Drawing.Imaging.ImageFormat.Jpeg);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号