Solved

Getting RGB values from BMP files

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Ho to creat split-view application in iPad that display PDF file?? 3 137
Adjust Mfcapp 29 155
List out all word 7 224
Line meaning 9 77
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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now