Look at GenerateMipMaps for details.
function ImGenerateMipMaps(const Image: TImageData; Levels: LongInt; var MipMaps: TImageDataList): Boolean; cdecl;
ImagingExport (at line 121)