#### Archived

This topic is now archived and is closed to further replies.

# Loaded BMP screwing up... yes I am doing the padding :)

This topic is 5835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

it like appears twice, on one side its half the size of the bmp - horizontaly... and then the top appears at twice the size over the top of it... the image is 200x200 as is the back surface...

#define RGB32(R, G, B) ((0 <<32) | (R << 16) | (G << 8) | (B))

{
DDSURFACEDESC2   surfaceDesc;
LPDIRECTDRAWSURFACE4 NewSurface;
DWORD             *bitmapData;
DWORD             *bitmapDone;
FILE             *bitmapFile;
BYTE             red, green, blue;

bitmapFile = fopen(filename, "rb");
// get the padding at the end of the bitmap

ZeroMemory(&surfaceDesc, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc);
surfaceDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
surfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

if(FAILED(g_pDDraw4->CreateSurface(&surfaceDesc, &NewSurface, NULL)))
{
MessageBox(g_hwnd, "NewSurface Failed", "ERROR", MB_ICONSTOP | MB_OK);
Log("NewSurface Failed");
return false;
}

ZeroMemory(&surfaceDesc, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc);
NewSurface->Lock(NULL, &surfaceDesc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
bitmapDone = (DWORD *)surfaceDesc.lpSurface;
{
{
bitmapData[y*infoheader.biWidth + x] = RGB32(red, green, blue);
}
// skip past the padding in the file

}

int heightIndex = 0;
{
bitmapDone[heightIndex*(surfaceDesc.lPitch/2) + x] = bitmapData[y*infoheader.biWidth + x];
++heightIndex;
}
delete bitmapData;
NewSurface->Unlock(NULL);
fclose(bitmapFile);
return NewSurface;
}

g_pBack->Blt(0, g_pSkin, 0, DDBLT_WAIT, &ddbltfx);

CEO Plunder Studios

##### Share on other sites
Quickly breezing through, shouldn''t:

quote:

bitmapDone[heightIndex*(surfaceDesc.lPitch/2) + x] = bitmapData[y*infoheader.biWidth + x];

be:

quote:

bitmapDone[heightIndex*(surfaceDesc.lPitch/4) + x] = bitmapData[y*infoheader.biWidth + x];

If your surface is 32bit that is.

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

##### Share on other sites
Thanks man your my hero! I had nearly given up there after spending the last hour and a half tinkering with every other peice of code I had... I thought I had narrowed it down to me having the size of the surface wrong as windows was over taking shit and so it would have been stretching it smaller... but O well!! I thought I had gotten to everything in that function... I guess it was sorta hard to see...

CEO Plunder Studios

• 10
• 16
• 14
• 18
• 15