Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading .BMP image

Status
Not open for further replies.

Tatchster

Programmer
Oct 13, 2002
3
AU
I have problem opening .BMP image files. I want to get
RGB of data from BMP image files and store it into 3 different arrays, red, green and , blue. But i dont know how to read the raw format. Can somebody tell me how?
 
I believe all you need to do is:


Code:
BITMAPFILEHEADER fh;
BITMAPINFOHEADER ih;

CFile f;
f.Open("mybitmap.bmp",CFile::modeRead);

f.Read(&fh,sizeof(fh));
f.Read(&ih,sizeof(ih));

int spp = ih.biBitCount/8;
int size = ih.biHeight * ih.biWidth*spp;

BYTE* buffer = new BYTE[size];
f.Read(buffer,size);


Buffer should contain the rgb data. You will want to make sure that spp is equal to 3 for rgb data. Also, I am not sure if this is 100% correct. I looked through some old code to find it. It is, however, along the correct path :)

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top