Screen capture and resize it in half


I am capturing a snapshot of the desktop and saving it to file in a bmp format. That unfortunately is 4.2 Mb which is absolutely huge. So I decided to save it as a jpg, and it has dropped the size to 1.4Mb which is better but still to big, so what I wanted to try was to use the paintpicture to half the size of the captured desktop.

Can you provide me with the code to ensure that the full desktop is still saved but is half in height and in width.

This is rather urgent, thus me awarding 500 pts.

Many thanks.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Use the code from here to capture the screen:;en-us;161299

Then you just need to PictureBoxes and code like the below to have and save it...

    Private Sub Command1_Click()
        Picture1.Appearance = 0 ' flat
        Picture1.BorderStyle = 0 ' none
        Picture1.AutoSize = True ' make sure autosize is on
        Set Picture1.Picture = CaptureScreen() ' capture the entire screen

        Picture2.Appearance = 0 ' flat
        Picture2.BorderStyle = 0 ' none
        Picture2.AutoSize = False ' we will set the size ourself
        Picture2.AutoRedraw = True ' otherwise we'll lose the image...
        Picture2.Width = Picture1.Width / 2 ' make it half the screen cap width
        Picture2.Height = Picture1.Height / 2 ' make it half the screen cap height
        ' draw the screen cap at half size from Pic1 to Pic2
        Picture2.PaintPicture Picture1.Picture, 0, 0, Picture2.Width, Picture2.Height
        SavePicture Picture2.Image, "c:\HalfDesktop.bmp" ' save it at half size
    End Sub
Shane Russell2nd Line Desktop SupportCommented:
What about this :

I found it on

If thats not what you are looking for please let me know :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shane Russell2nd Line Desktop SupportCommented:
I found this as well :)

It says its a must see for graphics programmers as it has coded example on how to scale images, as well as other effects :) so you just need to alter / use the code you require and intergrate it :)

The code Idle Mind should work, however I am curious as to whether it will work with jpegs or not ?

Only reason I say that is because you said you were using jpegs to decrease the file size :) Unless you know how to convert it from bmp once it has been halfed in size :P
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
The code I provided works in BMP format and also demonstrates how to scale an image.  Without APIs, you use the PaintPicture() method as in my example.

VB can LOAD a JPG, but CANNOT SAVE a JPG without the use of a third party control or DLL.

So the samples you provided gecko will also only save in BMP format as well.

Shane Russell2nd Line Desktop SupportCommented:
ah ok, I knew that there were 3rd party controls involved with regards to the saving of jpegs I was just curious about the jpeg part only because in the question he said that he made it into jpegs to save on space :)

I figured I would provide those examples just to give him a fully working example :) If the asker goes on to and searches for screen capture or w/e else they want, there is an abundance of examples with just about everything you can think of :)
tafAuthor Commented:
Hi all,

Thanks for getting back to me so quickly.

I will award the points to Idle mind as he was the first one to get back to me with this solution and it worked.

Unfortunately it is extremely dissapointing to see that appearance and scale is not kept properly. I have found another acceptable solution which is to zip the bmp before e-mailing it. It compresses 4.2mb into 157k which is a lot more acceptable.

Thanks to all anyway.

Shane Russell2nd Line Desktop SupportCommented:
Did you accept the wrong suggestion then because I have the points ?
tafAuthor Commented:
I did,

my apologies, it was meant to go to Idle Mind. I will contact the admin, and try to revert the problem.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.