# E:/DevIL/src-IL/src/il_dds-save.c File Reference

`#include "il_internal.h"`
`#include "il_dds.h"`
`#include "il_manip.h"`
`#include <limits.h>`

## Defines

#define | Sum(c) ((c)->r + (c)->g + (c)->b)
#define | NormSquared(c) ((c)->r * (c)->r + (c)->g * (c)->g + (c)->b * (c)->b)

## Functions

ILboolean | ilSaveDds (const ILstring FileName)
| Writes a Dds file.
ILuint | ilSaveDdsF (ILHANDLE File)
| Writes a Dds to an already-opened file.
ILuint | ilSaveDdsL (void *Lump, ILuint Size)
| Writes a Dds to a memory "lump".
ILuint | GetCubemapInfo (ILimage *image, ILint *faces)
| Checks if an image is a cubemap.
ILboolean | iSaveDdsInternal ()
ILboolean | WriteHeader (ILimage *Image, ILenum DXTCFormat, ILuint CubeFlags)
ILuint ILAPIENTRY | ilGetDXTCData (void *Buffer, ILuint BufferSize, ILenum DXTCFormat)
ILushort | As16Bit (ILint r, ILint g, ILint b)
ILushort * | CompressTo565 (ILimage *Image)
ILubyte * | CompressTo88 (ILimage *Image)
void | CompressToRXGB (ILimage *Image, ILushort **xgb, ILubyte **r)
ILuint | Compress (ILimage *Image, ILenum DXTCFormat)
ILboolean | GetBlock (ILushort *Block, ILushort *Data, ILimage *Image, ILuint XPos, ILuint YPos)
ILboolean | GetAlphaBlock (ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos)
ILboolean | Get3DcBlock (ILubyte *Block, ILubyte *Data, ILimage *Image, ILuint XPos, ILuint YPos, int channel)
void | ShortToColor565 (ILushort Pixel, Color565 *Colour)
void | ShortToColor888 (ILushort Pixel, Color888 *Colour)
ILushort | Color565ToShort (Color565 *Colour)
ILushort | Color888ToShort (Color888 *Colour)
ILuint | GenBitMask (ILushort ex0, ILushort ex1, ILuint NumCols, ILushort *In, ILubyte *Alpha, Color888 *OutCol)
void | GenAlphaBitMask (ILubyte a0, ILubyte a1, ILubyte *In, ILubyte *Mask, ILubyte *Out)
ILuint | RMSAlpha (ILubyte *Orig, ILubyte *Test)
ILuint | Distance (Color888 *c1, Color888 *c2)
void | ChooseEndpoints (ILushort *Block, ILushort *ex0, ILushort *ex1)
void | ChooseAlphaEndpoints (ILubyte *Block, ILubyte *a0, ILubyte *a1)
void | CorrectEndDXT1 (ILushort *ex0, ILushort *ex1, ILboolean HasAlpha)
void | PreMult (ILushort *Data, ILubyte *Alpha)
ILAPI ILubyte *ILAPIENTRY | ilCompressDXT (ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DXTCFormat, ILuint *DXTCSize)
| Compresses data to a DXT format using different methods.

## Define Documentation

#define NormSquared | ( | c |  | ) | ((c)->r * (c)->r + (c)->g * (c)->g + (c)->b * (c)->b)

Referenced by ChooseEndpoints().

#define Sum | ( | c |  | ) | ((c)->r + (c)->g + (c)->b)

Referenced by iluEqualize().

## Function Documentation

ILushort As16Bit | ( | ILint | r,
|  | ILint | g,
|  | ILint | b |
| ) |  |  |

Referenced by CompressTo565().

void ChooseAlphaEndpoints | ( | ILubyte * | Block,
|  | ILubyte * | a0,
|  | ILubyte * | a1 |
| ) |  |  |

Referenced by Compress().

void ChooseEndpoints | ( | ILushort * | Block,
|  | ILushort * | ex0,
|  | ILushort * | ex1 |
| ) |  |  |

Referenced by Compress().

ILushort Color565ToShort | ( | Color565 * | Colour | ) |

ILushort Color888ToShort | ( | Color888 * | Colour | ) |

Referenced by PreMult().

ILuint Compress | ( | ILimage * | Image,
|  | ILenum | DXTCFormat |
| ) |  |  |

Referenced by ilGetDXTCData(), iSaveDdsInternal(), iSaveSgiInternal(), and iSaveTargaInternal().

ILushort* CompressTo565 | ( | ILimage * | Image | ) |

Referenced by Compress().

ILubyte* CompressTo88 | ( | ILimage * | Image | ) |

Referenced by Compress().

void CompressToRXGB | ( | ILimage * | Image,
|  | ILushort ** | xgb,
|  | ILubyte ** | r |
| ) |  |  |

Referenced by Compress().

void CorrectEndDXT1 | ( | ILushort * | ex0,
|  | ILushort * | ex1,
|  | ILboolean | HasAlpha |
| ) |  |  |

Referenced by Compress().

ILuint Distance | ( | Color888 * | c1,
|  | Color888 * | c2 |
| ) |  |  |

Referenced by GenBitMask(), and iluReplaceColour().

void GenAlphaBitMask | ( | ILubyte | a0,
|  | ILubyte | a1,
|  | ILubyte * | In,
|  | ILubyte * | Mask,
|  | ILubyte * | Out |
| ) |  |  |

Referenced by Compress().

ILuint GenBitMask | ( | ILushort | ex0,
|  | ILushort | ex1,
|  | ILuint | NumCols,
|  | ILushort * | In,
|  | ILubyte * | Alpha,
|  | Color888 * | OutCol |
| ) |  |  |

Referenced by Compress().

ILboolean Get3DcBlock | ( | ILubyte * | Block,
|  | ILubyte * | Data,
|  | ILimage * | Image,
|  | ILuint | XPos,
|  | ILuint | YPos,
|  | int | channel |
| ) |  |  |

Referenced by Compress().

ILboolean GetAlphaBlock | ( | ILubyte * | Block,
|  | ILubyte * | Data,
|  | ILimage * | Image,
|  | ILuint | XPos,
|  | ILuint | YPos |
| ) |  |  |

Referenced by Compress().

ILboolean GetBlock | ( | ILushort * | Block,
|  | ILushort * | Data,
|  | ILimage * | Image,
|  | ILuint | XPos,
|  | ILuint | YPos |
| ) |  |  |

Referenced by Compress().

ILuint GetCubemapInfo | ( | ILimage * | image,
|  | ILint * | faces |
| ) |  |  |

Checks if an image is a cubemap.

Referenced by iSaveDdsInternal().

ILAPI ILubyte* ILAPIENTRY ilCompressDXT | ( | ILubyte * | Data,
|  | ILuint | Width,
|  | ILuint | Height,
|  | ILuint | Depth,
|  | ILenum | DXTCFormat,
|  | ILuint * | DXTCSize |
| ) |  |  |

Compresses data to a DXT format using different methods.

ILuint ILAPIENTRY ilGetDXTCData | ( | void * | Buffer,
|  | ILuint | BufferSize,
|  | ILenum | DXTCFormat |
| ) |  |  |

Referenced by ilCompressDXT(), and ilSurfaceToDxtcData().

ILboolean ilSaveDds | ( | const ILstring | FileName | ) |

Writes a Dds file.

Referenced by ilSave(), and ilSaveImage().

ILuint ilSaveDdsF | ( | ILHANDLE | File | ) |

Writes a Dds to an already-opened file.

Referenced by ilSaveDds(), and ilSaveF().

ILuint ilSaveDdsL | ( | void * | Lump,
|  | ILuint | Size |
| ) |  |  |

Writes a Dds to a memory "lump".

Referenced by ilDetermineSize(), and ilSaveL().

ILboolean iSaveDdsInternal | ( | void |  | ) |

Referenced by ilSaveDdsF(), and ilSaveDdsL().

void PreMult | ( | ILushort * | Data,
|  | ILubyte * | Alpha |
| ) |  |  |

ILuint RMSAlpha | ( | ILubyte * | Orig,
|  | ILubyte * | Test |
| ) |  |  |

void ShortToColor565 | ( | ILushort | Pixel,
|  | Color565 * | Colour |
| ) |  |  |

void ShortToColor888 | ( | ILushort | Pixel,
|  | Color888 * | Colour |
| ) |  |  |

Referenced by ChooseEndpoints(), GenBitMask(), and PreMult().

ILboolean WriteHeader | ( | ILimage * | Image,
|  | ILenum | DXTCFormat,
|  | ILuint | CubeFlags |
| ) |  |  |

Referenced by iSaveDdsInternal().