Take Full Screen Screenshot

Haxaro

Well-known member
Joined
Mar 13, 2009
Messages
105
Programming Experience
1-3
How can i take a full screen screenshot, that takes from the top left hand corner, down to the bottom right corner (underneath the taskbar). I have found heaps of samplecodes, but they all just take a shot of the current open window. please help :)
 
With reference to System.Drawing.Imaging
VB.NET:
Dim bounds As Rectangle = Screen.GetBounds(Point.Empty) 
Using bitmap As New Bitmap(bounds.Width, bounds.Height) 
    Using g As Graphics = Graphics.FromImage(bitmap) 
        g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size) 
    End Using 
    bitmap.Save("screen.png", ImageFormat.Png) 
End Using

dont save screenshots as jpeg; the compression isnt intended for use on images with sharp changes in contrast and colour
 
Sorry, but im looping this every 10 seconds, and after the first loop, it comes up with a "GDI generic Error"... any ideas?
 
Generic GDI+ Error

I know there are heaps of questions out there about the GDI+ Generic Error, but i can seem to find a fix for my problem.

I am taking a screenshot every 10 seconds, save it as a .gif, encrypt it, and the save the encrypted image to a different file named with the exact time.

Now, if i want this to be effective, i only want to have one .gif at a time, so how can i over write it again and again.

here is my screenshot code:
VB.NET:
    Dim bounds As Rectangle = Screen.GetBounds(Point.Empty)
        Using bitmap As New Bitmap(bounds.Width, bounds.Height)
            Using g As Graphics = Graphics.FromImage(bitmap)
                g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size)
            End Using
            bitmap.Save("C:\myimage.gif", ImageFormat.Gif)
        End Using

As it has to take a FULL SCREEN screenshot, but when it runs, it can keeps saving and sacing the file, because it comes up with the GDI+ Generic Error. Please Help :)
 
There's nothing wrong with your screenshot code. Probably your encrypting code is not closing the file after use, so Bitmap.Save isn't allowed to overwrite it.

regards, Vic
 
Back
Top