An alternative to the method Žarko Gajić described is the following code:
function ScaleImageList(Source: TCustomImageList; M, D: Integer): TCustomImageList;
const
ANDbits: array[0..2*16-1] of Byte = ($FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF);
XORbits: array[0..2*16-1] of Byte = ($00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00);
var
I: integer;
Icon: HIcon;
begin
Result := TCustomImageList.CreateSize(MulDiv(Source.Width, M, D), MulDiv(Source.Height, M, D));
if M = D then
begin
Result.Assign(Source);
Exit;
end;
Result.ColorDepth := cd32Bit;
Result.DrawingStyle := Source.DrawingStyle;
Result.BkColor := Source.BkColor;
Result.BlendColor := Source.BlendColor;
for I := 0 to Source.Count-1 do
begin
Icon := ImageList_GetIcon(Source.Handle, I, LR_DEFAULTCOLOR);
if Icon = 0 then
begin
Icon := CreateIcon(hInstance,16,16,1,1,@ANDbits,@XORbits);
end;
ImageList_AddIcon(Result.Handle, Icon);
DestroyIcon(Icon);
end;
end;
It is simpler and I think works better.