Solved

Getting RGB values from BMP files

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reading tzdatabase for timezone definitions 5 142
Estimate porting issues. 9 120
cURL: stopping a http transaction before it's finished 3 126
C hashtable library 3 100
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…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

809 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