Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: how to take a screenshot of a portion of screen

Tags:

like

TakeScreenshot(new Rectangle(0,0,100,100), "output.jpg"); 
like image 798
Louis Rhys Avatar asked Jul 22 '10 07:07

Louis Rhys


1 Answers

Use the following:

Rectangle rect = new Rectangle(0, 0, 100, 100); Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); bmp.Save(fileName, ImageFormat.Jpeg); 
like image 196
Marcel Gheorghita Avatar answered Oct 20 '22 07:10

Marcel Gheorghita