Search
Winners

Win Prizes

Social Presence
Like us on Facebook
Advertisements
Ads

Capture and save active window including taskbar.

Rajkatie
Posted by Rajkatie under C# on 3/3/2012 5:48:05 AM | Points: 75 | Views : 4901 | Status : [Member] [MVP]

try
            {
                
                using (Bitmap imageBmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Graphics.FromHwnd(IntPtr.Zero)))
                {
                
                    using (Graphics graphics = Graphics.FromImage(imageBmp))
                    {
                        graphics.CompositingQuality = CompositingQuality.HighQuality;
                        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        graphics.SmoothingMode = SmoothingMode.HighQuality;

                
                        graphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, imageBmp.Size, CopyPixelOperation.SourceCopy);
                        imageBmp.Save("d:\\temp.jpeg",ImageFormat.Jpeg);
                    }
                }
            }
            catch (Exception ex)
            {
                // log the exception

            }


Rajesh Patel
R.P.A Developer | Developer Trainer | Clean Code Evangelist

Comments or Responses


Login to post response