Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

getting RGB data from a BMP

Posted on 2003-12-11
5
337 Views
Last Modified: 2013-11-20
Hello people
I want to manipulate the RGB data for a windows BMP for image processing so how do i get the RGB array/matrix from a BMP image pleas help
0
Comment
Question by:cyberizen
5 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9920183
Since you are asking in the MFC-TA I suggest to load the bitmap into a CBitmap. Then you can get the RGB values into a buffer using GetBitmapBits:

CBitmap bmp;
HBITMAP hbmp = (HBITMAP) ::LoadImage (AfxGetInstanceHandle (), fileName, IBM_BITMAP, 0, 0, LR_LOADFROMFILE);
bmp.Attach (hbmp);

BITMAP bbmp;

bmp.GetObject (sizeof (bbmp), &bbmp);

DWORD nsize = bbmp.bmWidthBytes * bbmp.bmHeight;

BYTE *buf = new BYTE(nsize);
bmp.GetBitmapBits (nsize, buf);

....

delete buf

0
 
LVL 1

Author Comment

by:cyberizen
ID: 9921640
hello newbie here
well i have the BYTES now what next how do i extract the RED GREEN and BLUE values

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 11992087
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
post4 challenge 28 104
fix34  challenge 9 139
How do I get Window Title of all opened process? 4 11
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

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