EvilZone

Programming and Scripting => .NET Framework => Topic started by: bubzuru on August 01, 2012, 11:22:31 PM

Title: (C#) Take ScreenShot
Post by: bubzuru on August 01, 2012, 11:22:31 PM
Save (full)Screen Shot To The Disk

Code: (c#) [Select]
        //Save Screen Shot To Disk
        public void SaveScreenShot(string path)
        {
          Bitmap  bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,     Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
          Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
          gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
          bmpScreenshot.Save(path, System.Drawing.Imaging.ImageFormat.Png);
        }
Title: Re: (C#) Take ScreenShot
Post by: jyggorath on December 03, 2013, 10:18:22 AM
What libraries does Bitmap, Screen, Graphics, CopyPixelOperation and Imaging belong to?
Title: Re: (C#) Take ScreenShot
Post by: ArkPhaze on January 27, 2014, 03:51:52 AM
What libraries does Bitmap, Screen, Graphics, CopyPixelOperation and Imaging belong to?

You mean namespaces within the BCL? System.Drawing. Seems weird that he is explicitly showing that within the code on only some of the objects within the namespace, and not all, or... not declaring that the namespace is being used at the top and avoiding the explicit declarations within the function...

No call to Dispose() either anywhere here, which isn't very good.