Results 1 to 16 of 16

Thread: Storing and compressing an image in VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19

    Cool

    I would like to save an image in VB 6 in the least possible format.

    I would be thankful if anyone could help me in giving the method of saving the image and also any possible way to compress the image to the maximum possible extent and store it in a database.

    Thanking you

    Sreedhar

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Take a look at this: http://psprogramming.virtualave.net/...7/dd/zlib.html

    Ignore the DirectDraw part and download only the zlib.dll and the compression program (which includes source)...

    It uses zlib.dll to compress byte arrays, allowing it to be stored inside a database and reading it again without using a temporary file...

    Good luck!
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19

    Cool Thanks for the help

    Thanks a lot for the help, i am downloading the file, i will go through it. I download zlib_compress.zip but it isn't of much use but the .dll i hope it is.

    Thanks a lot and if any doubts i will ask you.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19
    The zlib.dll is not working. I am getting an error saying that the zlib.dll is not found so i tried to register the dll which failed.

    Can you tell me an alternative to this or am i doing anything wrong.

    Thank you

  5. #5
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    The DLL must be in the same path of your program, or (which should work for sure) put it in your Windows\System path...

    Included with the zlib_compress.zip are two class modules. One which handles the zLib.dll and the other one which is used to compress a bitmap (this had been designed for bitmaps only, not JPGs, because bitmaps are not yet compressed and can be read from a byte array to be blitted onto a picturebox or form).

    It's not extremely difficult to change the zlib_compress.zip example to work with a database, as long as you know how to store byte arrays. I normally create a field of the type dbLongBinary (or OLE_???? in Access if I'm correct)...

    If you need any more help or sample code, just leave a message here...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19

    Exclamation Compression of images not satisfactory

    PsychoMark

    Thanks a lot for the code. But the compression is not coming to the level i expected and it is infact quite more than .jpeg images.

    I wanted something which compresses files more than the .jpeg images.

    If you can help me i shall be thankful to you

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    JPEG is a quality reducing compression format, so you change the rate and can compress more to loose quality on the other hand.
    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.

  8. #8
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    I never really tested the JPG and my own method, but I'm sure they're not that different. Especially if you want to keep the quality (like kedaman said, JPGs look awful if you compress them a lot), and I needed the quality for DirectDraw...

    I think you'll have to make a choice between quality and size (unfortunately, VB doesn't support the PNG format, but I've heard the PNG format uses something similar to my zLib sample )...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19
    My main requirement is like this, we are developing a component using scanner which scans the image and stores the image. My colleagues have developed the component but the size of the file is quite big which is of A4 size. I have been assigned the task to see to it that i can reduce the size of the image to the maximum possible extent.

    If possible i would like a component to convert the bmp's into jpg's and compress them into a readable or non readable format to the maximum possible extent.

    If there is any component or software pls tell me

  10. #10
    Member
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    45
    You can set Jpeg quality to 1 and get the best compression rate... and one ugly pixel

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19
    my images need not be in .jpg format they can be in .tiff ,etc. I just need the least size without much compromising on the quality

  12. #12
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    So you want an incredibly tiny file without loosing too much quality? I think that's going to be hard to find, but if anyone here knows a way, I'm interested too....

    You could try to create JPG images with a reasonable quality and use RAR to compress those, but I only have the UnRAR code for that (because WinRAR only supplies an unrar.dll)...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19

    I want still smaller images

    What is RAR and UNRAR.

    I have used kodak components in VB and compressed a .bmp file of 2.59 mb to a minimum of 58.2 kb. But my boss wants still lesser size images. I have used jpeg compression of high compression and least quality and saved the file as .tif file.

    I have heard that its possible to reduce the same file i,e A4 size image to a minimum or around 20kb which is what i am trying now.

    If you know the method or any sites where such components are available can u tell me. It will be of great help.

  14. #14
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    RAR is something like Zip, only RAR is much better...

    What's the difference between 52 kb and 20 kb? Ok, 30 kb I can hear you say, but does it really matter that much? You'll probably have to spend a lot of money on 3rd party components to get that kind of compression rates...

    Anyways, I can't help you from this point, I can just say: good luck!
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Hyderabad
    Posts
    19
    Can u expand a little more on RAR and URAR and where can i get and what should i do.


    As you said 50 and 20 kb isn't much but when it comes to many files which are to be stored in database its a lot.

    Thanks a lot for the help.

  16. #16
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    WinRAR can be found at http://www.rarsoft.com/

    I think there are some examples at http://www.planetsourcecode.com/vb/ too, or try http://www.vbaccelerator.com/ and search for the ZIP functions in the 'Libraries' section...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

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