Solved

Getting RGB values from BMP files

Posted on 2003-11-02
2
670 Views
Last Modified: 2012-06-22
How would I go about loading a BMP file and reading RGB values from specific pixels in the picture?
For example, get the RGB value of pixel 100/50 (X/Y)

Code examples would be appreciated.

Yaniv
0
Comment
Question by:Yanivoliver
2 Comments
 
LVL 11

Expert Comment

by:dimitry
ID: 9666948
Take a look at BMP format. RGB values are stored as array. Link also contains C-code examples.
http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 200 total points
ID: 9667119
Yanivoliver:

> How would I go about loading a BMP file and reading RGB values from specific
> pixels in the picture?
> For example, get the RGB value of pixel 100/50 (X/Y)

> Code examples would be appreciated.

Look at this page:  http://www.gamedev.net/reference/articles/article1251.asp

Scroll down to the section called "Displaying Bitmaps With GDI".  It will show you how to load the bitmap into a Device Context (DC).  Then you can use the Win32 API function called "GetPixel" which returns the color of a pixel at the given coordinates.  That page covers that function as well.

Hope that helps,
Dex*
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question