I have a picturebox on the form, with BackgroundImage property set to certain image. The rest of the image has certain transparent areas, so that background image is shown in those areas. I want to save it to the file, but there is no save method for picturebox. There is a save method for image property, but then it only saves the content of the image, and does not include the backgroundimage. Any hints on how I can save both, so that it looks in the file exactly as it looks on the picturebox?
Asked
Active
Viewed 2,241 times
3 Answers
0
g.DrawLine(myPen, EX, EY, e.X, e.Y);
EX = e.X;
EY = e.Y;
DrawArea = (Bitmap)pictureBox1.Image.Clone();
pictureBox1.Image = DrawArea;
pictureBox1.Image.Save(@"D:\C#Test_Save_File\Arash_Bashiri.bmp", System.Drawing.Imaging.ImageFormat.Bmp); `
-
Hello maybe it is too late for your question but i have this Problem and could solve >it. we have 2 layer Image but by saving ,just on of them can save!!!! Befor saving you can combine both ,and this is possible with loading visual Situation befor saving . – Arash Bashiri May 13 '16 at 06:34
0
Try:
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, pictureBox1.CreateGraphics());
bmp.Save(@"BlaBlaBlaBla.Bla");
edit:
Bitmap b = new Bitmap(width, height);
Graphics g = Graphics.FromImage(b);
Then use the drawImage method of Graphics to draw background and foreground and save the bitmap.

Gilad Naaman
- 6,390
- 15
- 52
- 82
-
I didn't understand, where does this method save the image? How do I save it to file? – Tofig Hasanov Jul 09 '11 at 06:27
-
It didn't work. The file is created, but there is no image on it. Can it be because of transparent color use? – Tofig Hasanov Jul 09 '11 at 06:42
-
-
Maybe there is some other way to do what I want? My eventual goal is to create 2-layer picture, with one layer having some objects and rest filled with white color, which is set to be transparent, and the second layer is to become background for these objects. And I need to save this combination as a single image to a file. – Tofig Hasanov Jul 09 '11 at 06:46
-
-
Thanks for the suggestion. But I don't know how to draw it, since background is a photograph, and objects are portraits of people. – Tofig Hasanov Jul 09 '11 at 07:46
0
I have managed to accomplish this by simply combining two images together using graphics, and then saving the result as a single image object. Thus, I am not using background image anymore.

Tofig Hasanov
- 3,303
- 10
- 51
- 81