Create image with what is in a tab control c # [closed]

0

Hi, I wanted to know how I could create an image with everything inside a Tab Control, inside this I have several pictureboxes and the idea would be to create an image that shows all those pictureboxes I do not know if I made myself understand

    
asked by Crisheld 07.09.2017 в 18:26
source

2 answers

1
        Size s = actual.Size;
        Bitmap memoryImage;
        using (Graphics myGraphics = CreateGraphics())
        {
            memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
        }
        using (Graphics memoryGraphics = Graphics.FromImage(memoryImage))
        {
            Point screenPoint = PointToScreen(actual.Location);
            memoryGraphics.CopyFromScreen(screenPoint.X, screenPoint.Y + 10, 0, 0, s);
        }

        memoryImage.Save("imagen.png", ImageFormat.Png);

I do not know if this will work for someone in the future, but I do create a screenshot in the coordinates where this is my tabControl, which in that case is called current. I found this code here link

    
answered by 07.09.2017 в 19:03
0

Assuming that the tab you want to create is tabPage1, the code would be like this:

using (Bitmap bmp = new Bitmap(tabPage1.Width, tabPage1.Height))
{
   tabPage1.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));
   bmp.Save(@"C:\hola\ejemplo.png", System.Drawing.Imaging.ImageFormat.Png); 
}
    
answered by 07.09.2017 в 18:54