convert graphic to Bitmap [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this questionI am creating a Graphics object to draw on the original image and I want save the modified image as a new image.The Image on the form as well as the drawing
//load bitmap from file
Image bmp = Image.FromFile();
Graphics g = Graphics.FromImage(bmp);
//do drawing here with g.
bmp.Save();
g.Dispose()
Bitmap newBitmap = new Bitmap(originalBitmap);
using (Graphics myGraphics = Graphics.FromImage(newBitmap))
{
// draw here on myGraphics
}
// newBitmap - modified image
Alternatively with Load & Save:
Bitmap myBitmap = new Bitmap("fileName.bmp");
using (Graphics myGraphics = Graphics.FromImage(myBitmap))
{
// draw here on myGraphics
}
myBitmap.Save("newFileName.bmp");
精彩评论