# DirectDraw Surface File Format

# DirectDraw Surface File Format

The Microsoft DirectDraw Surface (.dds) file format is used to store textures and cubic environment maps, both with and without mipmap levels. This format can store uncompressed and compressed formats, and is the preferred file format for storing DXTn compressed data. This format was introduced with DirectX 7.0. In DirectX 8.0, support for volume textures was added. Many new games use DDS files to store their textures. More information on DDS files can be found in DirectX SDK documentation.
Imaging supports loading and saving of all three types of DDS files - standard textures, cube maps and volume textures. Each of these types can be with or without mipmaps and compressed with DXTC. Pixel formats of DDS files supported by Imaging can be found in the table below.

## DirectDraw Surface File Format Support

D3DFORMAT | TImageFormat equivalent | Loading | Saving
--- | --- | --- | ---
D3DFMT_R3G3B2 | ifR3G3B2 | Yes | Yes
D3DFMT_R5G6B5 | ifR5G6B5 | Yes | Yes
D3DFMT_X1R5G5B5 | ifX1R5G5B5 | Yes | Yes
D3DFMT_X4R4G4B4 | ifX4R4G4B4 | Yes | Yes
D3DFMT_R8G8B8 | ifR8G8B8 | Yes | Yes
D3DFMT_X8R8G8B8 | ifX8R8G8B8 | Yes | Yes
D3DFMT_A1R5G5B5 | ifA1R5G5B5 | Yes | Yes
D3DFMT_A4R4G4B4 | ifA4R4G4B4 | Yes | Yes
D3DFMT_A8R8G8B8 | ifA8R8G8B8 | Yes | Yes
D3DFMT_A16B16G16R16 | ifA16B16G16R16 | Yes | Yes
D3DFMT_L8 | ifGray8 | Yes | Yes
D3DFMT_A8L8 | ifA8Gray8 | Yes | Yes
D3DFMT_L16 | ifGray16 | Yes | Yes
D3DFMT_R32F | ifR32F | Yes | Yes
D3DFMT_A32B32G32R32F | ifA32B32G32R32F | Yes | Yes
D3DFMT_X8B8G8R8 | ifX8R8G8B8 | Yes | No
D3DFMT_A8B8G8R8 | ifA8R8G8B8 | Yes | No
D3DFMT_X8L8V8U8 | ifX8R8G8B8 | Yes | No
D3DFMT_Q8W8V8U8 | ifA8R8G8B8 | Yes | No
D3DFMT_Q16W16V16U16 | ifA16B16G16R16 | Yes | No
D3DFMT_V8U8 | ifA8Gray8 | Yes | No
D3DFMT_DXT1 | ifDXT1 | Yes | Yes
D3DFMT_DXT3 | ifDXT3 | Yes | Yes
D3DFMT_DXT5 | ifDXT5 | Yes | Yes

When working with DDS files you can find useful some options which can be set by SetOption function and their current values can be get by GetOption function. Or you can set them by modifying properties of TDDSFileFormat class. Options are divided into two groups - loading options and saving options. Loading options have prefix ImagingDDSLoaded and they store some properties of the last loaded DDS file. You can use saving options with prefix ImagingDDSSave to tell Imaging how to save the next DDS file (save settings persist until they are changed by SetOption call) - ordinary texture or volume texture with mipmaps or other? You can learn how to use these options and how to load and save DDS files in Loading and Saving DDS Files section.

## Options Related to DDS Files

OptionId | Allowed Values | Usage
--- | --- | ---
ImagingDDSLoadedCubeMap | 0 (false) or 1 (true) | Indicates whether the last loaded DDS file contained cube environment map or not.
ImagingDDSLoadedVolume | 0 (false) or 1 (true) | Indicates whether the last loaded DDS file contained volume texture or not.
ImagingDDSLoadedMipMapCount | 1 to N | Number of mip map levels of the last loaded DDS file.
ImagingDDSLoadedDepth | 1 to N | Depth (slices of volume texture or faces of cube map) of the last loaded DDS file.
ImagingDDSSaveCubeMap | 0 (false) or 1 (true) | Indicates whether DDS files will be saved as cube environment map or not. Default value is 0 (false).
ImagingDDSSaveVolume | 0 (false) or 1 (true) | Indicates whether DDS files will be saved as volume texture or not. Default value is 0 (false).
ImagingDDSSaveMipMapCount | 1 to N | Number of mip map levels to be saved to the next saved DDS file. Default value is 1.
ImagingDDSSaveDepth | 1 to N | Depth (slices of volume texture or faces of cube map) of the next saved DDS file. Default value is 1.