Screen capture and resize it in half

Hi,

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.

Thierry
tafAsked:
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 TomlinsonMiddle School Assistant TeacherCommented:
Use the code from here to capture the screen:
http://support.microsoft.com/default.aspx?scid=kb;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
0
Shane Russell2nd Line Desktop SupportCommented:
What about this :

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=26915&lngWId=1

I found it on www.pscode.com

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

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 :)

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=11543&lngWId=1

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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mike TomlinsonMiddle School Assistant TeacherCommented:
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.

~IM
0
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 www.pscode.com 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 :)
0
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.

Thierry
0
Shane Russell2nd Line Desktop SupportCommented:
Did you accept the wrong suggestion then because I have the points ?
0
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.

Thanks.

Thierry
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.