In Lazarus 2.X TCustomImageList.InsertMasked now inserts a single image only by scaling entire Bitmap to a single icon.
lcl/include/imglist.inc:procedure TCustomImageList.InsertMasked(Index: Integer; AImage: TCustomBitmap;
MaskColor: TColor);
var
MaskedImage: TBitmap;
ScBmp: TRGBAQuadArray;
R: TCustomImageListResolution;
begin
if AImage = nil then Exit;
MaskedImage := TBitmap.Create;
try
MaskedImage.Assign(AImage);
MaskedImage.TransparentColor := MaskColor;
MaskedImage.TransparentMode := tmFixed;
MaskedImage.Transparent := True;
CreateDefaultResolution;
for R in Resolutions do
begin
ScaleImage(MaskedImage.BitmapHandle, MaskedImage.MaskHandle, Rect(0, 0, MaskedImage.Width, MaskedImage.Height), R.Width, R.Height, ScBmp);
R.InternalInsert(Index, @ScBmp[0]);
end;
finally
MaskedImage.Free;
end;
end;
Previously in Lazarus 1.X multiple bitmaps were inserted basing on the bitmap width (bitmap width / imagelist width). Currently there is AddSliced function which allows multiple insertion but it does not support Index and a MaskColor.
Is this a bug or feature? Is there a simple way to return the previous behaviour? Or we have to use helpers to access private functions (CreateDefaultResolution, InternalInsert)?
P.S. Using a temporary masked bitmap resolves MaskColor applying. However Index support requires more effort.