want to read gif/jpeg in C/c++

This is a discussion on want to read gif/jpeg in C/c++ within the C Programming forums, part of the General Programming Boards category; hello every one. i have tried the code posted on this site for reading images from C but it is ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    9

    want to read gif/jpeg in C/c++

    hello every one.

    i have tried the code posted on this site for reading images from C
    but it is restricted to only 16 bit .Bmp images only.

    i want to generalise it for the gif/jpeg formats(famous in internet)
    which are widely used.

    can any one help with required guidelines & suggestion



    thank u all

  2. #2
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Reading gif/jpeg is a TINY bit different than reading a bmp.

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by orbitz
    Reading gif/jpeg is a TINY bit different than reading a bmp.
    heh, a bit of an understatement

  5. #5
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    .GIF (pronounced "JIFF") is a proprietary format owned by CompuServe. with that said, you can find old tutorials on how to read/write it. You want probably GIF 32a.

    It is much different than JPG/JPEG formats. GIF is a "lossless" algorithm-- no original data is lost. JPG/JPEG (Joint Photographic Experts Group) on the other hand is a "lossy" format. It discards "least significance" data in the rasterization (quantum) process. That's why JPG/JPEG images can be adjusted in size/quality-- how much data is thrown away determines how big the file is.

    I've written both algorithms, and JPG/JPEG is by far the more difficult-- in fact, it's amazing how fast JPG/JPEG algorithms work, given the amount of code in them.
    It is not the spoon that bends, it is you who bends around the spoon.

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,255
    GIF is not "owned" by CompuServe, it's "owned" by the Unisys Corporation. One of those bland, evil American companies that looks perfectly harmless on the outside but they wear shiny uniforms and manufacture larger and larger death rays, so that one day they can death ray the entire world!!!

    Not as bad as Microsoft, mind.

    Anyways, Unisys doesn't "own" the GIF format as such, but they do have a patent out on the LZW implementation required to compress/decompress the data inside the GIF format.

    My advice would be to seek out the Portable Network Graphics (PNG) format. It's free to use and pretty nifty too (Supports alpha channels, 32-bit image data, etc.). 'Tis the fooooooooooooootchaaaaaaaaaa...
    Last edited by SMurf; 12-09-2002 at 11:58 AM.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Personally, I prefer TIFF. TIFF is the easiest format to read and write I've ever seen. Blissfully easy.

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    TIFF's are good and all, but JPEGS are really the best overall, they provide a very good compression ratio (lossy though) and are much more widely supported.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by master5001
    TIFF's are good and all, but JPEGS are really the best overall, they provide a very good compression ratio (lossy though) and are much more widely supported.
    Yeah. I know why he wanted to read .JPG/.GIF. For my own use, because it's so easy, I prefer TIFF. If you're picking one to learn on they're a good starter. Very simple format. Easy to create your own images.

    Or you could just use Java, which natively supports both JPG and GIF...

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    There are libraries that come with support for jpegs and gifs. I think if you are just getting started TIFFs aren't a bad way to go. I started off with bmp's which have some characteristics that make then a little harder for a newbie (which I wasn't when I started w/ bmp's). Java has better support for interacting with c programs now days, if only this were actually useful.

  11. #11
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    Intel used to have a free JPEG lib, but they scrapped it for a more powerful one that does lot's more stuff. I've seen JPEG algos and they're frightening! Truly wiz-kid stuff.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    hehehe JPEGs are quite an advanced image format. Writing a JPEG reader by hand (not recommended) calls for algorithms such as Discrete Cosine Transformations and Huffman Coding. It is all fun stuff that will give you a head-ache.

  13. #13
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    GIF is not "owned" by CompuServe, it's "owned" by the Unisys Corporation
    Sorry, my bad. The reason it is commonly mentioned in collusion with Compuserve, rather than Unisys (you are correct) is because the original announcement was made by CompuServe, not Unisys when Unisys tried to enforce its patent. Here's specific info if you want it--

    http://lpf.ai.mit.edu/Patents/Gif/Gif.html
    It is not the spoon that bends, it is you who bends around the spoon.

  14. #14
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    This is a windows only, JPEG only solution using the Intel Jpeg Library. I'll try to post the manual in next post.
    For portable alternatives:
    http://sourceforge.net/projects/freeimage
    http://www.ijg.org/files/

    Have Fun!
    Attached Files Attached Files

  15. #15
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    This is the manual. Sorry about the poor format but the pdf version was 205KB.
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 06-17-2008, 11:38 AM
  2. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 02:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21