Here's a trick where you have a single dim array (e.g. bitmap bits); you like to keep it stored this way for easy writing back to disk.
//Before you can write bmp bits to it...
BYTE* lpBits;
lpBits = (BYTE *)calloc(biWidth * biHeight, sizeof(BYTE));
//Writing data from bmp file to lpBits
...here...
//It would be easy though to index the bmp in 2D, no?
//We create an array of byte pointers for each line...
BYTE** lppBits;
lppBits = (BYTE**)calloc(biHeight, sizeof(BYTE*));
//Now we set the pointers to the beginning of each row...
int R=0, iOffset=0;
while(R < biHeight){
lppBits[R] = &lpBits[iOffset];
iOffset += biWidth;
R++;
}
//Now you're able get each bmp color index like this...
BYTE tiColor;
int R, C;
R=0;
while(R < biHeight){
C=0;
while(C < biWidth){
tiColor= lppBits[R][C];
C++;
}
R++;
}