Original Post
I am having trouble with getting a bitmap to display correctly in directdraw. I’m currently using this excerpt of code I copied from Tricks of Gaming Guru and for some reason my bitmap comes out distorted when blittered.
Check out the difference: http://pages.sbcglobal.net/kenjisamurai/happy.gif
(the gray is where the transparency is and yes the original pictures are 24bit bitmaps)
Could this code be the culprit or something else?
somesurface->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);
DWORD * tsome_buffer = (DWORD *)ddsd.lpSurface;
// process each line and copy it into the primary buffer
for (int index_y = 0; index_y < PICTOHEIGHT; index_y++)
{
for (int index_x = 0; index_x < PICTOWIDTH; index_x++)
{
// get BGR values
UCHAR blue = (bitmap.buffer[index_y*PICTOWIDTH*3 + index_x*3 + 0]),
green = (bitmap.buffer[index_y*PICTOWIDTH*3 + index_x*3 + 1]),
red = (bitmap.buffer[index_y*PICTOWIDTH*3 + index_x*3 + 2]);
// this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)
DWORD pixel = _RGB32BIT(0,red,green,blue);
// write the pixel
SOME_buffer[index_x + (index_y*ddsd.lPitch >> 2)] = pixel;
} // end for index_x
} // end for index_y
// now unlock the primary surfac
if (FAILED(somesurface->Unlock(NULL)))
return(0);