Results 1 to 35 of 35

Thread: Image Compressing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Image Compressing

    I'm working on a project which requires me store images from image control / picture box as a physical file. I've tried using SavePicture Command, but it stores only in BMP format which takes up a lot of space.

    I would like to store it in a compressed format, so that the image occupies minimal amount of space say below 1KB.


    Anybody who can help me out regarding this
    Pavan Kumar

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    what format would you like to compress it in, i happen to have source for jpeg compression
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    Any type of format is OK for me even JPG as long as it offers the level of compression I need, ie., some where below 1KB
    Pavan Kumar

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    depends, compression level is defined as a ratio of the outcome data by the original. JPEG reduces the quality until a specified ratio is obtained
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    can u send me the jpeg source u have
    Pavan Kumar

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yeah i could if you give me your email ad
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    my e-mail id : [email protected]
    Pavan Kumar

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    ----- The following addresses had permanent fatal errors -----
    <mailto:[email protected]>
    (reason: 550 Invalid recipient: <"mailto:pavan_crm"@excite.com>)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    I could not get ur mail. Pls. mail me again

    My email ID : Pavan ([email protected])
    Last edited by pavan; May 1st, 2001 at 11:25 PM.
    Pavan Kumar

  10. #10
    Addicted Member
    Join Date
    Feb 2001
    Posts
    162

    Over here too please:P

    Lo Kedaman

    can you also send me the source please

    [email protected]

    thank you

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    n/p
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    sorry but I didnt catch ur meanining in N/P
    Pavan Kumar

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    no problem.
    btw, i'm had problem sending the mail, but now it succeeded, did you recieve it?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    Thanx for ur reply. I think i got ur mail but i'm unable to view my inbox due to bad NET connection I'll try it again and let u know of it
    Pavan Kumar

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Thanx

    Thanks Kedaman. I've got ur mail and have downloded it. I'm right now goin thru it and I find it very usefule.


    Thanks again.
    Pavan Kumar

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Query

    Hi kedaman


    I've gone thru ur code. Its compression capability is good. But I want to know how to restore the original image, after compressing it, with the same quality.


    Thanx in Advance.
    Pavan Kumar

  17. #17
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    You can't, you need to use other graphics formats...

    I've created my own with a little compression, you can find it here: http://psprogramming.virtualave.net/...7/dd/zlib.html
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  18. #18
    Member Fleming's Avatar
    Join Date
    Feb 2001
    Location
    My chair, my house, my street, my town, my county, England (the wettest place on earth!).
    Posts
    35

    Me too!

    Hi kedaman,

    Could you send me the code too.

    [email protected]

    Thanks in advance.

    Sean.

  19. #19
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Fleming: Sure.
    pavan: A quality reducing format like jpeg looses quality every time you compress it, there's no way to restore it. Gif compression doesn't reduce the size as much as jpeg but keeps the quality, although with a max 256 color palette.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  20. #20
    Dreamlax
    Guest
    Hey Kedaman, can you send it to me (sorry I'm late) please?

    [email protected]

    BTW, the comma or fullstop in your signiture, is that your site? And howcome I'm not welcome? No, what I mean to have said is who is welcome?

  21. #21
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    ok sent, yeah it's my homepage, and youre welcome to the site, if you check it out
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    hi

    Hi psychomark,

    I've seen ur page and also downloaded the dlls. but the problem is they work only with BMPs whereas i need the compression utility for JPGs or GIFs which originally occupy a very little space.
    Pavan Kumar

  23. #23
    Member Fleming's Avatar
    Join Date
    Feb 2001
    Location
    My chair, my house, my street, my town, my county, England (the wettest place on earth!).
    Posts
    35
    Hi kedaman,

    If you have already sent me the file, or even if you haven't, could you please resend it to:
    [email protected]

    another.com is way too slow, it takes ages for anything to get through.

    Fleming.

  24. #24
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    PNG format is compressed, and it isn't lossy. Maybe you could find some source for that somewhere.
    Harry.

    "From one thing, know ten thousand things."

  25. #25
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    The reason I used BMP's for the compression, is that I can draw them using the raw byte data, whereas JPG's and GIF's would require you to unpack the file to disk first, then load it (using for example LoadPicture). If you don't mind temporary files, you can just compress and uncompress the pictures using the zLib.dll...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  26. #26

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Thanx

    Thanx Psychomark for giving me the advice I will try ur advice.
    Pavan Kumar

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Hi

    Hi PsychoMark,

    I've tried compressing and decompressing of JPGs with zlib.dll as u suggested.

    But while compressing the compresion ratio seems to be very little / negligble for JPGs. the compressed file was only a few bytes smaller than the original file.


    And while decompressing it, I repeatedly got an error saying 'out of stack space'.


    can u help me out of it.

    Thanx in Advance
    Pavan Kumar

  28. #28
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    1. The low compression ratios are not that strange, since JPG's are already compressed. For example, use WinZip to compress a Bitmap and a JPG in the same way, you'll notice that the JPG isn't compressed as much as the BMP.

    2. Can't do anything without code, so if you still want to compress JPGs, send the code which you used to compress it, and mark the line where the error occurs...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Reply

    Hi Psychomark,


    I haven't changed much the code i've downloaded. I'm getting any error at clsBitmap.cls file. Anyway I'm sending it to u as attached Zipped file
    Last edited by pavan; May 21st, 2001 at 04:59 AM.
    Pavan Kumar

  30. #30
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Code:
        ' Create a bitmap out of the Byte array
        cBitmap.ReadFromByteArray bData()
    This is not possible, since we're reading JPG's. Comment the line out, and do the same for these:

    Code:
        cBitmap.ResizePicturebox picImage
        cBitmap.BlitToDC picImage.hDC
        picImage.Refresh

    Haven't tested it, but it should work. The errors are occuring because you're trying to read the bitmap format from a JPG, which could cause VB to crash...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134
    Hi,

    I've tried all the advices given to me but the compressed file size seems to be a min. of 1.3KB max. its not going down further. i require the compressed image to be less than 1 KB. I've also tried reading the image pixel by pixel and storing it in the file with all the common colors codified ( an idea from vbsquare.com) but even then it has come to 1.2KB. so if anybody out ther can tell me how to achieve this i'll be thankful


    Thnx in advance
    Pavan Kumar

  32. #32
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Can you give me the image you want to compress? If so, I can check some other possibilities...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  33. #33

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    hi

    Hi PsychoMark

    The image i want to compress is not specific. It ithe photograph of a person. U can take any photograph of a person and then try out the possibilities.
    Pavan Kumar

  34. #34
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Ic, well, let me know the average dimensions then, since the file size can vary a lot depending on the dimensions...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Dimensions

    Hi

    I've a requirement of Image dimensions are as follows.

    The dimensions for one image are 19.05 x 25.4 mm / 0.75 x 1.0 inch

    the dimensions for the other are 25.4 x 6.35 mm / 1.0 x 0.25 inch


    all the dimensions are Width x Height
    Pavan Kumar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width