From 5493650684bdaa457c67078cec81e59f0eee1110 Mon Sep 17 00:00:00 2001 From: ondrej Date: Thu, 1 Feb 2018 16:59:15 +0000 Subject: [PATCH] lcl: imagelist: add TCustomImageList.AddSlice function. Issue #33114 git-svn-id: trunk@57207 - --- lcl/imglist.pp | 1 + lcl/include/imglist.inc | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lcl/imglist.pp b/lcl/imglist.pp index 6513ca328d..b672e0aa5b 100644 --- a/lcl/imglist.pp +++ b/lcl/imglist.pp @@ -296,6 +296,7 @@ type function Add(Image, Mask: TCustomBitmap): Integer; function AddSliced(Image: TCustomBitmap; AHorizontalCount, AVerticalCount: Integer): Integer; + function AddSlice(Image: TCustomBitmap; AImageRect: TRect): Integer; function AddIcon(Image: TCustomIcon): Integer; procedure AddImages(AValue: TCustomImageList); function AddMasked(Image: TBitmap; MaskColor: TColor): Integer; diff --git a/lcl/include/imglist.inc b/lcl/include/imglist.inc index 844340e4b7..2456ae0cc9 100644 --- a/lcl/include/imglist.inc +++ b/lcl/include/imglist.inc @@ -1180,6 +1180,24 @@ begin Grp.Free; end; +function TCustomImageList.AddSlice(Image: TCustomBitmap; AImageRect: TRect + ): Integer; +var + R: TCustomImageListResolution; + ScBmp: TRGBAQuadArray; +begin + if Image = nil then Exit(-1); + + Result := Count; + + CreateDefaultResolution; + for R in Resolutions do + begin + ScaleImage(Image, nil, AImageRect, R.Width, R.Height, ScBmp); + R.InternalInsert(Result, @ScBmp[0]); + end; +end; + function TCustomImageList.AddSliced(Image: TCustomBitmap; AHorizontalCount, AVerticalCount: Integer): Integer; var @@ -2036,9 +2054,13 @@ begin for X := SourceRect.Left to SourceRect.Right do for Y := SourceRect.Top to SourceRect.Bottom do begin - C := II.Colors[X, Y]; - if (AMask<>0) and II.Masked[X, Y] then - C.Alpha := 0; + if (X>=0) and (X=0) and (Y0) and II.Masked[X, Y] then + C.Alpha := 0; + end else + C := colTransparent; FI.Colors[X-SourceRect.Left, Y-SourceRect.Top] := C; end;