sailing

Everything...

Simple and easiest way to make a screen shot in .net 2.0

In the days before .net 2.0, you have to make a directly call into "gdi32.dll" to get a full screen shot. Now, .net 2.0 has included this powerful function: (enjoy it )

        private void GetAScreenShot()

        {

            this.Opacity = 0;

            Screen ScreenDimension = Screen.PrimaryScreen;

            Bitmap BmpScreenShot = new Bitmap(ScreenDimension.Bounds.Width, ScreenDimension.Bounds.Height);

            Graphics DesktopGraphics = Graphics.FromImage(BmpScreenShot);

            DesktopGraphics.CopyFromScreen(

                0,  //sourceX

                0,  //sourceY

                0,  //destX

                0,  //destY

                new Size(ScreenDimension.Bounds.Width, ScreenDimension.Bounds.Height)

                );

            BmpScreenShot.Save("d:\\temp.bmp");

            DesktopGraphics.Dispose();

            BmpScreenShot.Dispose();

            this.Opacity = 100;

        }

posted on 2006-04-16 15:02  乌生鱼汤  阅读(433)  评论(2编辑  收藏  举报

导航