so simple. ddraw

Started by
0 comments, last by stevenmarky 23 years, 11 months ago
How do you get the dimentions (x,y) of a bitmap stored in a surface? I know this is a real easy question, so please help me? Thanks in advance. //end
Advertisement
IDirectDrawSurface7::GetSurafaceDesc(LPDDSURFACEDESC2 lpddsurfacedesc)

This is the function which fills in a surface description of a surface. You then get DDSURFACEDESC.dwWidth and dwHeight to get the width and height of the surface.

Example:

LPDIRECTDRAWSURFACE lpdds;
DDSURFACEDESC2 ddsd;
int width,height; // integers to hold the width and
//the height of the surface

// Initialise it and do all the stuff you were planning to
// do

memset(&ddsd, 0, sizeof(ddsd)); // Erase the surface desc
ddsd.dwSize = sizeof(ddsd); // Set the size
lpdds->GetSurfaceDesc(&ddsd); // Retrieve a description
width = ddsd.dwWidth; // Assign the variables
height = ddsd.dwHeight;

That is if you want the size of a surface.

If you want the actual width of a bitmap inside the surface which doesn''t cover the whole thing, you''d have to lock the surface and then iterate through the pixels until you found the right edge of the bitmap, incrementing the width variable, and do the same with the height.

This topic is closed to new replies.

Advertisement