Howdy.. I''m working through a book that i picked up recently..
"Windows Game Programming for Dummies" By Andre LaMothe..
anywho.. in Chapter 10 it''s explain how to load fullscreen bitmaps, and the source code on the cd is supposed to demonstrate that. Now.. when you compile and run the program, (Prog10_5.cpp for anybody that has read this book) when you give it a 24bit bitmap to display, it corrupts the color scheme horribly. Almost completely green. Now when i checked the source i noticed that if the bitmap of the given file is 24bit, the program automatically converts it to 16bit. I don''t know if the bitmap was supposed to be displayed in green, but somehow i don''t think so. If you just load up the source .bmp in paint or whatever it looks fine.. so I guess what i''m asking is, can anybody help me out with the following algorithm? I think the problem is that it''s not addressing the red components of the bitmap properly but i could be way off. I understand the indexing of the loop, but the >> shift right operator has me a little confused. More than likely due to my less-than-adequate knowledge of how these colors, (8/16/32bit), are built up. any advice would be helpful.
// now convert each 24 bit RGB value into a 16 bit value
for (index=0; index < bitmap->bitmapinfoheader.biWidth*
// extract RGB components (in BGR order), note the scaling
UCHAR blue = (temp_buffer[index*3 + 0] >> 3),
green = (temp_buffer[index*3 + 1] >> 3),
red = (temp_buffer[index*3 + 2] >> 3);
// build up 16 bit color word
USHORT color = _RGB16BIT(red,green,blue);
// write color to buffer
((USHORT *)bitmap->buffer)[index] = color;
} // end for index
temp_buffer is a temporary placeholder for the 24bit bitmap, memory allocated accordingly
bitmap->buffer is the actual working bitmap structure.. I''m guessing that the r,g,b components of temp_buffer must be copied here.
_RGB16BIT is a macro designed to build up a 16 bit color
hmm.. if you could point me toward a site that could help me understand how these colors are built up, and how to index through them properly.. that would probably be the best solution, but thanks for any advice
If i remember correctly (i read that book a very long time ago) the a. lamothe gives instructions in the extras / something like that folder on the cd. I remember that his code was only ready to load 8 - bit bitmaps. On his site or somewhere on the cd, he gives an article on loading 24/16 bit bitmaps. good luck
LaMothe has 16 bit versions of all the functions on the CD but this should replace LaMothe's Load_Bitmap_File16() because his only works on 565 video cards, not 555. All his other functions should work though...
int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
// this function opens a bitmap file and loads the data into bitmap
int file_handle, // the file handle
index; // looping index
UCHAR *temp_buffer = NULL; // used to convert 24 bit images to 16 bit
OFSTRUCT file_data; // the file data information
// open the file if it exists
if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)