Click here to Skip to main content
15,850,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I have a program that automatically print screen every second an save the image using a timer. Its working well, my problem is that its eating may disk space 1 file = 120KB. Is there a way to do this which will not require much disk space... maybe a video, gif anything.

Please help.. Thanks in advance

I use this function to get the desktop image (found this on the Internet)
Private Function CaptureScreen(ByVal locX As Integer, ByVal locY As Integer, ByVal width As Integer, ByVal height As Integer) As Bitmap
    Dim NewImage As New Bitmap(width, height)
    Dim g As Graphics = Graphics.FromImage(NewImage)
    g.CopyFromScreen(locX, locY, 0, 0, NewImage.Size)
    Return NewImage
End Function

In my Timer (1000 second interval)
If Not IO.Directory.Exists("C:\Folder\") Then IO.Directory.CreateDirectory("C:\Folder\")
Dim bit As Bitmap = CaptureScreen(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
bit.Save("C:\Folder\" & Format(Now, "yyyyMMdd hhmmss") & ".jpg", Imaging.ImageFormat.Jpeg)
Updated 3-Oct-13 1:13am
Richard MacCutchan 3-Oct-13 6:08am    
That would make no difference. If each image takes 120K then it would use almost as much in a video stream. You could try using some better compression.
Sriram Bala 3-Oct-13 7:21am    
Instead of .jpf format, you can try .gif format this will save you some space.
hansoctantan 3-Oct-13 7:30am    
I will try, thanks...
hansoctantan 3-Oct-13 7:33am    
you are correct, gif cuts half the size but the quality is bad..
I don't know if what i did is correct change this to Imaging.ImageFormat.Jpeg = Imaging.ImageFormat.Gif
hansoctantan 3-Oct-13 7:35am    
also the site you given, my browser cant load the images... I don't know why?

1 solution

No, the comments above point into the totally wrong direction. The compressed file format does hardly matter, that can make up just a few percent.
What really makes a difference is the concept: instead of storing the whole screen everytime, store the difference to the previous screen only. That is, first picture is full screen, and later on it is most often almost nothing which needs to be stored. Find a way to detect the difference, and to encode them such taht you can restore the current screen. For long-term recordings, it could be appropriate to save the full screen from time to time, thus adjusting the base line.
Share this answer
member 8888995 4-Nov-13 1:36am    
hi Bernhard Hiller,
can you please tell how to find difference to previous screen programmatically?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900