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
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
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
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);
}