mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 14:40:29 +02:00
added implementation for TCustomImageList.ReplaceMasked
git-svn-id: trunk@13090 -
This commit is contained in:
parent
9d26c55e9a
commit
08608057d5
@ -128,6 +128,7 @@ type
|
|||||||
procedure InternalInsert(AIndex: Integer; AImage, AMask: HBitmap;
|
procedure InternalInsert(AIndex: Integer; AImage, AMask: HBitmap;
|
||||||
AWidth, AHeight: Integer);
|
AWidth, AHeight: Integer);
|
||||||
procedure InternalMove(ACurIndex, ANewIndex: Cardinal; AIgnoreCurrent: Boolean);
|
procedure InternalMove(ACurIndex, ANewIndex: Cardinal; AIgnoreCurrent: Boolean);
|
||||||
|
procedure InternalReplace(AIndex: Integer; AImage, AMask: HBitmap);
|
||||||
function InternalSetImage(AIndex: Integer; AImage: TRawImage): PRGBAQuad;
|
function InternalSetImage(AIndex: Integer; AImage: TRawImage): PRGBAQuad;
|
||||||
procedure NotifyChangeLink;
|
procedure NotifyChangeLink;
|
||||||
procedure SetBkColor(const Value: TColor);
|
procedure SetBkColor(const Value: TColor);
|
||||||
|
@ -768,6 +768,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomImageList.InternalReplace(AIndex: Integer; AImage,
|
||||||
|
AMask: HBitmap);
|
||||||
|
var
|
||||||
|
RawImage: TRawImage;
|
||||||
|
R: TRect;
|
||||||
|
ImgData: PRGBAQuad;
|
||||||
|
begin
|
||||||
|
if (AIndex < 0) then AIndex := 0;
|
||||||
|
CheckIndex(AIndex);
|
||||||
|
|
||||||
|
R := Rect(0, 0, FWidth, FHeight);
|
||||||
|
RawImage_FromBitmap(RawImage, AImage, AMask, R);
|
||||||
|
ImgData := InternalSetImage(AIndex, RawImage);
|
||||||
|
if HandleAllocated
|
||||||
|
then TWSCustomImageListClass(WidgetSetClass).Replace(Self, AIndex, ImgData);
|
||||||
|
|
||||||
|
FChanged := true;
|
||||||
|
Change;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomImageList.InternalSetImage
|
Method: TCustomImageList.InternalSetImage
|
||||||
Params: AIndex: the index of the location where the image should be set
|
Params: AIndex: the index of the location where the image should be set
|
||||||
@ -1173,25 +1193,14 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomImageList.Replace(AIndex: Integer; AImage, AMask: TBitmap);
|
procedure TCustomImageList.Replace(AIndex: Integer; AImage, AMask: TBitmap);
|
||||||
var
|
var
|
||||||
RawImage: TRawImage;
|
|
||||||
R: TRect;
|
|
||||||
ImgData: PRGBAQuad;
|
|
||||||
msk: THandle;
|
msk: THandle;
|
||||||
begin
|
begin
|
||||||
if (AIndex < 0) then AIndex := 0;
|
if AImage = nil then Exit;
|
||||||
CheckIndex(AIndex);
|
|
||||||
|
|
||||||
if AMask = nil
|
if AMask = nil
|
||||||
then msk := 0
|
then msk := 0
|
||||||
else msk := AMask.Handle;
|
else msk := AMask.Handle;
|
||||||
R := Rect(0, 0, FWidth, FHeight);
|
InternalReplace(AIndex, AImage.Handle, msk);
|
||||||
RawImage_FromBitmap(RawImage, AImage.Handle, msk, R);
|
|
||||||
ImgData := InternalSetImage(AIndex, RawImage);
|
|
||||||
if HandleAllocated
|
|
||||||
then TWSCustomImageListClass(WidgetSetClass).Replace(Self, AIndex, ImgData);
|
|
||||||
|
|
||||||
FChanged := true;
|
|
||||||
Change;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1224,13 +1233,22 @@ end;
|
|||||||
Every occurance of MaskColor will be converted to transparent.
|
Every occurance of MaskColor will be converted to transparent.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomImageList.ReplaceMasked(Index: Integer; NewImage: TBitmap; MaskColor: TColor);
|
procedure TCustomImageList.ReplaceMasked(Index: Integer; NewImage: TBitmap; MaskColor: TColor);
|
||||||
|
var
|
||||||
|
AMask: TBitmap;
|
||||||
begin
|
begin
|
||||||
if (Index >= FCount)
|
if NewImage = nil then Exit;
|
||||||
then raise EInvalidOperation.Create(SInvalidIndex);
|
|
||||||
|
|
||||||
if (Index < 0) then Index := 0;
|
AMask := TBitmap.Create;
|
||||||
|
with AMask do
|
||||||
|
begin
|
||||||
|
Height := NewImage.Height;
|
||||||
|
Width := NewImage.Width;
|
||||||
|
Assign(NewImage);
|
||||||
|
Mask(MaskColor);
|
||||||
|
end;
|
||||||
|
|
||||||
{$note implement}
|
InternalReplace(Index, NewImage.Handle, AMask.Handle);
|
||||||
|
AMask.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user