0

I tried with the graphics.Save();

Graphics newImage = Graphics.FromImage(bmp2);
newImage.DrawImage(bmp, 87, 37, 0, 0);
newImage.Save();

but when i try to set the file name like in the Image.Save(@"HereGoesName.PNG"); method i get an error saying "No overload for the method 'Save' takes 1 arguments)"

and everywhere i searched says to do the following

 Bitmap bitmap = new Bitmap(Convert.ToInt32(1024), Convert.ToInt32(1024), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 Graphics g = Graphics.FromImage(bitmap);
 bitmap.Save(@"HereGoesName.PNG", ImageFormat.Png);

From what i understand this is to create a graphics from a bitmap in here and i am trying to do the oposite.

Chona Pardo
  • 25
  • 2
  • 9

2 Answers2

4

You need to call Save on the bitmap, not the graphics:

Graphics newImage = Graphics.FromImage(bmp2);
newImage.DrawImage(bmp, 87, 37, 0, 0);
bmp2.Save("HereGoesName.PNG", ImageFormat.Png);
Matias Cicero
  • 25,439
  • 13
  • 82
  • 154
2

This is simple: Your line Graphics newImage = Graphics.FromImage(bmp2); creates a graphics object referring to bmp2 image.

All drawing actions draw direct on your bmp2 Bitmap

So you can simply save your modified image with:

bmp2.Save(@"foo.png", ImageFormat.Png);
TaW
  • 53,122
  • 8
  • 69
  • 111
MaxKlaxx
  • 713
  • 7
  • 9