How to get the rgb pixel values from a bmp image

This is a discussion on How to get the rgb pixel values from a bmp image within the C Programming forums, part of the General Programming Boards category; Dear all, I have some device specific driver in C code which gives a bmp image (640x480) as an output. ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Red face How to get the rgb pixel values from a bmp image

    Dear all,

    I have some device specific driver in C code which gives a bmp image (640x480) as an output. However I am having a serious trouble with extracting the RGB values from a bmp image (32bpp i guess). I have only a basic understanding of bmp formats and need to retreive the pixel RGB values to save it into a ppm format for further manipulation. There is a structure RGBQUAD inside the code too. I tried to download some libraries but was very unlucky either to read bmp or convert to ppm. Please can anyone direct me to some useful information and example code to accomplish this task.

    Thank you very much in advance for your time.

    anan

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    Just google "bmp file format".
    There's plenty of good info to read.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,602
    Quote Originally Posted by Salem View Post
    Just google "bmp file format".
    There's plenty of good info to read.
    +1, also if you search the forum you'll surely find a lot of information!
    Devoted my life to programming...

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    Your goal is to convert BMP to PPM? Why bother writing a program? Install ImageMagick and run:

    convert image.bmp image.ppm

    Presto.
    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. saving bmp image files
    By aniramg69 in forum C Programming
    Replies: 10
    Last Post: 12-30-2008, 09:08 AM
  2. Prob with padding in BMP image files
    By tin in forum Game Programming
    Replies: 2
    Last Post: 01-09-2006, 07:23 AM
  3. Reading color tiff images?
    By compz in forum Game Programming
    Replies: 1
    Last Post: 11-20-2003, 11:48 PM
  4. How to change a mouse cursor in console mode
    By GaPe in forum Windows Programming
    Replies: 10
    Last Post: 07-03-2002, 07:42 AM

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