Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

I have a "PictureBox" with an image and a "Button" control which has been added to "PictureBox" controls.

Now I want to save image of "PictureBox" with image which has been created from Button Appearance(Graphic + Text + ...) and save all as an single image.

how can I change Object's appearance to image and treat with them as an "image" after that?

I hope that my question was clear. thanks

What I have tried:

I tried to run a loop in picturebox.controls and create a ton of craphic and ...
Posted
Updated 2-Dec-18 10:06am

 
Share this answer
 
An Image is a picture which is displayed in a Picture box, is all - any other controls you add to the PictureBox.Controls collection aren't actually drawn on the Image at all, they are drawn on the screen (or other Graphics context used to displaying the PictureBox) but do not in any way, shape, or form alter the Image property.

If you want to modify the Image, your have to get a graphics context for it, and draw onto that.

But ... if you want to take a "snapshot" of the picturebox complete with Image and controls on top of it, look at ethe Graphics.CopyFromScreen Method (System.Drawing) | Microsoft Docs[^] - it should let you do that onto a new bitmap, which you can do what you like with afterwards.
 
Share this answer
 
 
Share this answer
 
Found a solution that also works when the Windows text size is not set to the default 100%, the PictureBox and other controls must be placed in a Panel:
Bitmap printscreen = new Bitmap(panel1.Bounds.Width, panel1.Bounds.Height);
panel1.DrawToBitmap(printscreen, panel1.ClientRectangle);
printscreen.Save(@"Screendump.jpg", ImageFormat.Jpeg);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900