I have some sample code here. I'm using mode 13h, compiled it with the old Borland C 3.0, and I'm using the standard libraries. It ignores palette data, so you may want to change that. It can display monochrome bitmaps, and 256 color ones. I was too lazy to implement 16colors...
I used this code in a game...
Code:
int putimage_BMP_1bit (char filename[], int x, int y, int zero, int one)
{
// Variables
dword width, height, offset;
dword i, j, counter = 0, by = 0;
byte ch[1];
byte header[54], array[8];
// Open image file
ifstream in (filename, ios::binary);
if (!in) return -1;
// Read and process header
in.read (header, 54);
if (header[0] != 0x42 || header[1] != 0x4D) return -2;
offset = todword (header, 10);
width = todword (header, 18);
height = todword (header, 22);
if (header[28] != 0x01 && header[29]!=0x00) return -3;
in.seekg (offset);
// Read and display image
for (i = height; i > 0; i--) {
for (j = 0; j < width; j++) {
if (counter % 8 == 0) {
if (by % 4 == 0) by = 0;
in.read (ch, 1);
tobinary (ch[0], array);
by++;
}
if (array[counter%8] == 0 && zero>=0) putpixel (j+x, i+y, zero);
if (array[counter%8] == 1 && one>=0) putpixel (j+x, i+y, one);
counter++;
}
while (by<4) {
in.read (ch, 1);
by++;
}
while (counter%8 != 0) counter++;
}
// Cleanup*/
in.close();
return 0;
}
int putimage_BMP_8bit (char filename[], int x, int y)
{
// Variables
dword width, height, offset;
dword i, j, counter = 0;
byte ch[4];
byte header[54], array[2];
// Open image file
ifstream in (filename, ios::binary);
if (!in) return -1;
// Read and process header
in.read (header, 54);
if (header[0] != 0x42 || header[1] != 0x4D) return -2;
offset = todword (header, 10);
width = todword (header, 18);
height = todword (header, 22);
// if (header[28] != 0x08 && header[29]!=0x00) return -3;
in.seekg (offset);
// Read and display image
for (i = height; i > 0; i--) {
for (j = 0; j < width; j++) {
if (counter % 4 == 0) {
in.read (ch, 4);
}
putpixel (j+x, i+y, ch[counter%4]);
counter++;
}
while (counter%8 != 0) counter++;
}
// Cleanup*/
in.close();
return 0;
}
You can use wikipedia to see how bitmaps look like, I mean the header and the data how it's structured.
http://en.wikipedia.org/wiki/BMP_file_format