Link to home
Start Free TrialLog in
Avatar of Marcelo-RJ
Marcelo-RJ

asked on

Convert BMP format to JPG format

I send to clipboard a snapshot of the DeskTop and I need to Save this snapshot into JPG or JPEG format. I know how to send a picture to clipboard in bynary format but when I want to save this picture to a file it becomes too large 1,37MB and with JPG format it will be 47Kb.

Here is my code. Please someone help me!

Function SendSnapshot()
    ''
    On Error Resume Next
    ''
    Dim StrSnapshot As String
    ''
    Call keybd_event(vbKeySnapshot, 1, 0&, 0&)
    DoEvents
    ''
    Pct_Snapshot.Picture = Clipboard.GetData(vbCFBitmap)
    Call SavePicture(Pct_Snapshot.Image, "C:\Windows\Temp\Image.bmp")
    ''
    Open "C:\Windows\Temp\Image.jpg" For Binary Access Read As #1
        StrSnapshot = Space(LOF(1))
        Get 1, , StrSnapshot
    Close #1
    ''
End Function
ASKER CERTIFIED SOLUTION
Avatar of TheQuestion
TheQuestion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, If you are tyring to send a screen shot across a network or the internet, I acctually had this problem just a few weeks ago, Belive it or not, JPEG is not the best way to go for Size vs Quality ratio. What I found is that I can take a 24bit bmp which is the best quality and quality will not decrease and compress it, it would be smaller than a JPEG. If you want I wrote a ActiveX dll that will take a screen shot, resize it to the demensions you want, save it to the quality you want (24bit, 256 color, 16 color or Monocrhome) and then save the file either as a BMP or Compressed. I can give you the ActiveX dll and the code to decompress and display the image in a Picture box if you want.


-Brian
BTW, using my ActiveX dll, I was able to take a 24bit screen shot and compress it down to just 30kb :-)


-Brian
Avatar of Marcelo-RJ
Marcelo-RJ

ASKER

Sure Brian! Can you send me this ActiveX dll?
Thanks TheQuestion!

It worked as I wanted!