Is it possible to create a JPG from a Control?
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);
精彩评论