Solved

Getting RGB values from BMP files

Posted on 2003-11-02
2
674 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

679 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