Transforming a content into an image

Asked

Viewed 58 times

1

I’m creating a project in Windows Forms to help my company generate automated email signatures for our employees.

I have in the case a single windows Forms that contains a Tab Control, with Data and Preview. In the preview tab there is a Picturebox with some Labels above it that is where the data of the collaborator will be inserted.

My question is, how can I get the entire contents of this Preview tab saved to an image? (. jpg, . png, etc)

Follow example images below:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • If the email client is outlook: Ever thought about developing an outlook plugin? By doing this it is possible to change the sender’s signature (in text).

  • It is not for outlook.. And yes, I had already thought this way if it were the case. :(

  • Here in the company has a similar system, where the signature is generated in HTML. When generating the signature opens the browser and the user uses CTRL+A and CTRL+C to copy and paste the email signature.

1 answer

1


One way would be to use the classes Bitmap and Graphics to make a screenshot. I did not test and I do not know if it will work, but it follows a code that shows an example of how to do screenshot of your entire desktop - maybe you can adapt it to take only from your program:

//Criar um novo bitmap.
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                               Screen.PrimaryScreen.Bounds.Height,
                               PixelFormat.Format32bppArgb);

// Criar um objecto de graphics do bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

// Tira a screenshot do canto superior esquero até o canto inferior direito
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                            Screen.PrimaryScreen.Bounds.Y,
                            0,
                            0,
                            Screen.PrimaryScreen.Bounds.Size,
                            CopyPixelOperation.SourceCopy);

// Salvar o screenshot na pasta desejada
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);

Inspired by that answer soen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.