Im trying to print (show in screen ) a screenshot on my main monitor , I think I’ve got all the necessary variables to make that happen but I have no clue how to get past
You'll need to call print(Bitmap, PaintEventArgs)
within the form Paint
event.
Try this
private void Form1_Load(object sender, EventArgs e)
{
Paint += new PaintEventHandler(Form1_Paint); //Link the Paint event to Form1_Paint; you can do this within the designer too!
}
private void print(Bitmap BM, PaintEventArgs e)
{
Graphics graphicsObj = e.Graphics; //Get graphics from the event
graphicsObj.DrawImage(BM, 60, 10); // or "e.Graphics.DrawImage(bitmap, 60, 10);"
graphicsObj.Dispose();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = Screen.PrimaryScreen.Bounds;
int color = Screen.PrimaryScreen.BitsPerPixel;
PixelFormat pf;
pf = PixelFormat.Format32bppArgb;
Bitmap BM = new Bitmap(rect.Width, rect.Height, pf); //This is the Bitmap Image; you have not yet selected a file,
//Bitmap BM = new Bitmap(Image.FromFile(@"D:\Resources\International\Picrofo_Logo.png"), rect.Width, rect.Height);
Graphics g = Graphics.FromImage(BM);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, rect.Size);
Bitmap bitamp = new Bitmap(BM);
print(bitamp, e);
}
Thanks,
I hope you find this helpful :)