DirectX SDK |
To describe a compressed texture surface in the DDSURFACEDESC2 structure when creating the surface, you must include the following steps:
There are two ways to load image data into a compressed texture surface:
Note When you call IDirectDrawSurface7::Lock or IDirectDrawSurface7::GetSurfaceDesc on a compressed surface, the DDSD_LINEARSIZE flag is set in the dwFlags member of the DDSURFACEDESC structure, and the dwLinearSize member contains the number of bytes allocated to contain the compressed surface data. The dwLinearSize parameter resides in a union with the lPitch parameter, so these parameters are mutually exclusive, as are the flags DDSD_LINEARSIZE and DDSD_PITCH.
To describe a compressed texture surface in the DDSURFACEDESC2 type when creating the surface, you must include the following steps:
There are two ways to load image data into a compressed texture surface:
Note When you call DirectDrawSurface7.Lock or DirectDrawSurface7.GetSurfaceDesc on a compressed surface, the DDSD_LINEARSIZE flag is set in the lFlags member of the DDSURFACEDESC2 type, and the lLinearSize member contains the number of bytes allocated to contain the compressed surface data. The lLinearSize parameter resides in a union with the lPitch parameter, so these parameters are mutually exclusive, as are the flags DDSD_LINEARSIZE and DDSD_PITCH.
The advantage of this behavior is that an application can copy the contents of a compressed surface to a file without having to calculate for itself how much storage is required for a surface of a particular width and height in the specific format.
The following table shows the five types of compressed textures. For more information on how the data is stored (you need to know this only if you are writing your own compression routines) see Compressed Texture Formats.
FOURCC | Description | Alpha premultiplied? |
---|---|---|
DXT1 | Opaque / one-bit alpha | n/a |
DXT2 | Explicit alpha | Yes |
DXT3 | Explicit alpha | No |
DXT4 | Interpolated alpha | Yes |
DXT5 | Interpolated alpha | No |
Note When you blit from a non-premultiplied format to a premultiplied format, DirectDraw scales the colors based on the alpha values. Blitting from a premultiplied format to a non-premultiplied format is not supported. If you try to blit from a premultiplied-alpha source to a non-premultiplied-alpha destination, the method will return DDERR_INVALIDPARAMS. If you blit from a premultiplied-alpha source to a destination that has no alpha, the source color components, which have been scaled by alpha, will be copied as is.