Ok, I've been writing some framework for a game, but I haven't gotten very far due to the fact that I can't load a 16-bitmap correctly. If the macro and code look weird, yell at Andre LaMothe, it's his book I'm reading
#define _RGB16BIT565(r,g,b) ((r%32) + ((g%64)<<6) + ((b%32)<<11)) //This is the macro to smash the bytes together
///////////////////////////////////////////
lpddsprimary->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
USHORT *vidbuffer = (USHORT *)ddsd.lpSurface;
for(int y=0;y{
for(int x=0;x{
UCHAR blue = bitmap.buffer[(y*IMAGE_HEIGHT*2+x*2)],
green = bitmap.buffer[(y*IMAGE_HEIGHT*2+x*2)],
red = bitmap.buffer[(y*IMAGE_HEIGHT*2+x*2)];
USHORT pixel = _RGB16BIT565(red,green,blue);
vidbuffer[x+y*(ddsd.lPitch/2)] = pixel;
}
}
///////////////////////////////////////////
The bitmaps being loaded are actual 16-bit, not 24. The above code makes a wonderful greyscale picture of whatever bitmap I've loaded. If I shift a few bits here or there, I manage to get some rather 'interesting' effects, but I just can't get the actual bitmap with the right colors to display.
Oh, and if it matters, the bitmaps were created in Ulead Video Paint and saved as 16-bit bitmaps.
Thanks in advance...