简体   繁体   中英

in GDI+ how to pass graphics to image

In C# I am drawing things on panel using creategraphics , and I need to pass these things to an image or a bitmap, how can I do that? thank you

You can draw directly to an Image by calling Graphics.FromImage .

You can draw a Control to a Bitmap by calling Control.DrawToBitmap


By the way, the correct way to draw to a control is to handle its Paint event and draw to e.Graphics in it. If you draw a control using CreateGraphics , it will be erased when the control is redrawn (eg, if you drag a window over it pre-Vista)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM