Original Post
Ok, maybe someone new looking at this problem can help me out. I'm loading a bitmap with the following code, and then transfering it to a DDraw surface, and blitting it. The only problem is, there are blank lines on the image blted to the screen. I've narrowed it down to either the bitmap loader or the bitmap to surface function. The bitmap does not have any padding issues(its DWORD aligned) and I am converting to the right 16-bit mode. Heres the coder for the loader:
And now heres the part that copies the bitmap from buffer to a surface.
Any ideas at this point would be MUCH appreciated. I'm sick of staring at my screen trying to figure out whats wrong.
-Chris
EDIT: Fixed the formatting
Edited by - Turtlebread on August 5, 2001 6:48:46 PM
for(iHeight = spBitmap->infoheader.biHeight - 1; iHeight >=0; iHeight --){
for(iWidth = 0; iWidth < spBitmap->infoheader.biWidth*2; iWidth += 2){
//read in one pixel, converting it to either RGB 565 or 555
//and switching it from BGR to RGB
file.get((char&)sTemp.blue);
file.get((char&)sTemp.green);
file.get((char&)sTemp.red);
//convert the pixel to 16 bit
wColor = Convert16(sTemp.red, sTemp.green, sTemp.blue);//Converts it to a 16-bit WORD value
//store low-end of WORD
spBitmap->buffer[iHeight*spBitmap->infoheader.biWidth+iWidth] = wColor & 0xFF;
//The buffer is a BYTE buffer that IS big enough to hold everything
//store high-end of WORD
spBitmap->buffer[iHeight*spBitmap->infoheader.biWidth+iWidth + 1] = wColor>>8;
}
}
|
wBitmap_Buffer = (WORD*)spBitmap->buffer;//Again, BUFFER points to a BYTE buffer
wScreen_Buffer = (WORD*)SurfaceDesc.lpSurface; //make the buffer valid
//Now copy the bitmap to the newly locked surface
for(y = 0; y < spBitmap->infoheader.biHeight; y++)
{
//copy the bitmap one line at a time
memcpy((void*)wScreen_Buffer,
(void*)wBitmap_Buffer,
spBitmap->infoheader.biWidth*2);
//advance pointers
wScreen_Buffer += SurfaceDesc.lPitch;
wBitmap_Buffer += spBitmap->infoheader.biWidth;
}
|