Thread: How to get the rgb pixel values from a bmp image

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    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
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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, 10:08 AM
  2. Prob with padding in BMP image files
    By tin in forum Game Programming
    Replies: 2
    Last Post: 01-09-2006, 08:23 AM
  3. Reading color tiff images?
    By compz in forum Game Programming
    Replies: 1
    Last Post: 11-21-2003, 12:48 AM
  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