getting RGB data from a BMP

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
LVL 1
cyberizenAsked:
Who is Participating?
 
Computer101Commented:
PAQed, with points refunded (50)

Computer101
E-E Admin
0
 
SteHCommented:
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
 
cyberizenAuthor Commented:
hello newbie here
well i have the BYTES now what next how do i extract the RED GREEN and BLUE values

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.