• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

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
0
taf
Asked:
taf
  • 4
  • 2
  • 2
1 Solution
 
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
 
gecko_au2003Commented:
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
 
gecko_au2003Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now