Thread: C++ JPEG Handling...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    22

    C++ JPEG Handling...

    Does anyone know any good libraries for handling images?

    At the very least I would like to display the image on screen and be able to zoom into it.

    A library is useful, but if there are any tutorials anyone is aware of on how to do the basics of this without using external libraries that will also be useful.

  2. #2
    a newbie :p
    Join Date
    Aug 2008
    Location
    Zurich, Switzerland, Switzerland
    Posts
    91
    Plenty i think. u can use libjpeg itself. or may be you want to use cxImage. you can even use openCV.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    22
    Quote Originally Posted by auralius View Post
    Plenty i think. u can use libjpeg itself. or may be you want to use cxImage. you can even use openCV.
    Thanks auralius. Those look pretty good, if libjpeg doesn't do it, the openCV library looks good. I'll have a look at those.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    my personal favorite is cximage

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    libjpeg will load the pixels from the file. It doesn't provide any calls to display the image or scale it. You're probably looking at three components:

    1. Something to load the JPEG (libjpeg is fine)
    2. Something to perform viewing -- determining windows and scales
    3. Something to actually scale the image
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    a newbie :p
    Join Date
    Aug 2008
    Location
    Zurich, Switzerland, Switzerland
    Posts
    91
    using libjepeg we can decompress image file, then get the raw data, later we can put it to device context to manipulate it. cximage and opencv make it a lot easier.

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    On Windows, you don't need anything.
    JPEG and any graphic format are native in Win32
    2 lines of code to load and display it with Win32 api...

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Alex31 View Post
    On Windows, you don't need anything.
    JPEG and any graphic format are native in Win32
    2 lines of code to load and display it with Win32 api...
    Zoom and pan in 2 lines of code?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by brewbuck View Post
    Zoom and pan in 2 lines of code?
    Perhaps not two lines (because you probably need to perform 3-4 calculations of the x/y coordinates,etc), but it really doesn't take a whole lot when using
    StretchBlt.

    You would probably want to SetStretchBltMode to HALFTONE if your pictures are photos or similar.

    I wrote a piece of code that displays images in a box of 500 x 400 pixels, and the actual drawing of the image is between 6-12 lines of code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Sep 2007
    Posts
    22
    Quote Originally Posted by Alex31 View Post
    On Windows, you don't need anything.
    JPEG and any graphic format are native in Win32
    2 lines of code to load and display it with Win32 api...
    I guess I am looking for something a bit more cross-platform.

    Thanks for the other replies. I hope to be able to sit down and try something a little later this week. This should be very helpful.

  11. #11
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by matsp View Post
    Perhaps not two lines (because you probably need to perform 3-4 calculations of the x/y coordinates,etc), but it really doesn't take a whole lot when using
    StretchBlt.
    I guess it wouldn't occur to me to use GDI scaling because I think it's so bad.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. signal handling and exception handling
    By lehe in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2009, 10:01 PM
  2. Handling critical errors
    By Memloop in forum C Programming
    Replies: 14
    Last Post: 03-26-2009, 06:14 AM
  3. event handling is serialized in MS Visual Studio C++ 2005 ??
    By mynickmynick in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2008, 04:47 AM
  4. C++ Equivalent JPEG Functions?
    By stickman in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2006, 10:50 AM
  5. JPEG from resource with GDI+
    By lord mazdak in forum Windows Programming
    Replies: 4
    Last Post: 04-05-2006, 04:23 PM