Bitmap to JPEG compression without storing into a .jpg file?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Bitmap to JPEG compression without storing into a .jpg file?

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Posts
    20

    Question Bitmap to JPEG compression without storing into a .jpg file?

    Hello gurus,

    could you please help me with my goal? I would like to compress the incoming raw image data (bitmap) from the usb camera in order not to stress the RAM memory. My first thought is then to use the JPEG compression. I have searched for a library or GDI function on the internet, which would offer it, but I have found only the way, where the raw image data is compressed by saving it into a .jpg file. I wish not to have it in a file, but in a memory buffer as compressed array of bits. Is it possible in general? If yes, how to do it? Thank you.

    best regards,

    Vitali

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Bitmap to JPEG compression without storing into a .jpg file?

    Last edited by olivthill2; April 22nd, 2011 at 06:31 AM.

  3. #3
    Join Date
    Apr 2011
    Posts
    20

    Question Re: Bitmap to JPEG compression without storing into a .jpg file?

    Is it possible to manage the compression procedure in that way that the compression is done step by step, with increasing quality until certain data size is reached, then the compression should stop?

    I mean the size of the image depends on the content of the image. If the content of the image has got many different textures, then it has got larger size as the one with large smooth areas.

    However, I would like to have a data container with a fixed size, thus the compression should be stopped earlier of later with regard to the occupied data size.

    Could you advice me or tell me, which jpeg compression library supports it or some algorithm that can do it? Thanks.

  4. #4
    Join Date
    Apr 2009
    Posts
    598

    Re: Bitmap to JPEG compression without storing into a .jpg file?

    You could have a loop. You start with low quality. If the image is too big, you stop. Otherwise you increase the quality and start again until you reach 100% or have a greater size than your limit.
    Of course, I guess you would like to avoid a loop, but I dion't think this could easily be done.

    Yes, the size depends on the image. Some images can be more compressed than others.

    The JPEG comittee has thought about limitations of the size of the buffer, especially because they worked on this project when computers had far less memory than today. One of the interesting solutions they devised, is the ability to process stripes of an image instead of the whole image at once.

    I am not aware there are a lot jpeg compression libraries out there. Have you visited the JPEG website ( http://www.jpeg.org/ )? Do you see several libraries, except when there is an upgrade or a version for a specific platform? Yes, there is jpeg and jpeg2000, but who uses jpeg2000? If you want to distribute your pictures and the user can't read them, then it is not worth using a non standard library.

  5. #5
    Join Date
    Apr 2011
    Posts
    20

    Re: Bitmap to JPEG compression without storing into a .jpg file?

    Thank you for helping, Olivthill!

    Your first response was helpful. Actually, I thought, I have to implement the jpeg_memory_dest by myself, but I have found out that it is already done in the new version of libjpeg (ver8c available at www.ijg.org). I'm using this successfully right now. So, this is also the answer to you second post. The libjpeg is quite useful. The only thing is that I have to find out, how can I compress the images until certain fixed memory size and stop the compression if the size is reached.

    I read that this library allows to compress in a progressive mode. May be it is the solution for me.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center