Thread: How can i read .bmp, .jpeg image in C language?

  1. #1
    Registered User
    Join Date
    Jul 2008

    Arrow How can i read .bmp, .jpeg image in C language?

    Is there any in built function by which one can directly read or access image files?
    Last edited by nnhamane; 07-09-2008 at 03:23 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Depends on what you mean by "access" - fopen("myimage.jpg", "rb") would open a jpg in binary form. But if "access" means that you can actually get to the pixels in a x,y format, then that's quite far from what you need, since JPG (and BMP to a lesser extent) are not just an array of pixels, but contains meta-data and in the JPG case is compressed in such a way that you would process the input quite a bit to get it into an array of pixels.

    There are image libraries (jpeglib for example) that can work with images.

    Windows also has functions that allow you to load images as bitmaps (JPEG, BMP, TIFF, PNG, etc), and further functions to use those bitmaps for various purposes (as a source or destination of drawing functions, for example).

    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.

  3. #3
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    images == complicated things at first

    You should understand their headers and algorithm to parse them.

    Using image libraries will be very helpful.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Hi matsp & audinue,
    Thankx for your reply.
    Actually i want to read each pixel of image, it may be of any type. For exa take .ppm image file, which contains less information. But i don`t know the exact structure of header or pixel. I am interested in C/C++ only. Plz tell me something about how to open image headers or pixels in C/C++? or tell me any sitename where i can found all information.
    Last edited by nnhamane; 07-20-2008 at 11:55 PM.

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    The RFCs (if they exist) for the image formats or other documentation... you have a LONG road ahead of you if you plan to write it all yourself.

    Google is a good website to start.

  6. #6
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Umeň, Sweden
    libjpeg is a fine choice for reading JPEGs, as for BMP I can't think of any portable library as I mostly use it with Windows API. Finding something to care of BMPs shouldn't be hard as it is a really simple format, pretty much a pixel array with a header. You could probably write one yourself with a bit of research.

  7. #7
    Registered User
    Join Date
    Sep 2006
    If you search, you may find the BMP display mode that was worked on and posted here on the forum, some months back.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  2. Need help for Read 2 Dimention barcode from image
    By ooosawaddee3 in forum C Programming
    Replies: 2
    Last Post: 01-28-2002, 09:23 AM
  3. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  4. LiNi - New Interpreted Language, READ!
    By minime6696 in forum Windows Programming
    Replies: 0
    Last Post: 12-24-2001, 01:43 PM
  5. How to read a image in C++?
    By DramaKing in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2001, 12:34 AM