mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:19:22 +02:00
Merged revision(s) 56974 #3da6552057 from trunk:
IDE: IDEImagesIntf: support transparent bitmaps. Issue #32947 ........ git-svn-id: branches/fixes_1_8@57259 -
This commit is contained in:
parent
5e483185ba
commit
f73c372d7d
@ -229,6 +229,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
aBitmap := CreateBitmapFromRes(ImageName);
|
aBitmap := CreateBitmapFromRes(ImageName);
|
||||||
Result := 100;
|
Result := 100;
|
||||||
|
if (aBitmap is TBitmap) and (aBitmap.PixelFormat in [pf1bit..pf24bit]) then
|
||||||
|
begin
|
||||||
|
aBitmap.TransparentColor := aBitmap.Canvas.Pixels[0, aBitmap.Height-1];
|
||||||
|
aBitmap.Transparent := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TIDEImages.CreateImage(ImageSize: Integer; ImageName: String
|
class function TIDEImages.CreateImage(ImageSize: Integer; ImageName: String
|
||||||
@ -310,8 +315,13 @@ begin
|
|||||||
if Grp=nil then
|
if Grp=nil then
|
||||||
raise Exception.CreateFmt('TIDEImages.LoadImage: %s not found.', [ImageName]);
|
raise Exception.CreateFmt('TIDEImages.LoadImage: %s not found.', [ImageName]);
|
||||||
if Grp is TCustomBitmap then
|
if Grp is TCustomBitmap then
|
||||||
Result := List.Add(TCustomBitmap(Grp), nil)
|
begin
|
||||||
else
|
if (Grp is TBitmap) and Grp.Transparent and (TBitmap(Grp).TransparentColor<>clNone)
|
||||||
|
and (TBitmap(Grp).PixelFormat in [pf1bit..pf24bit]) then
|
||||||
|
Result := List.AddMasked(TBitmap(Grp), TBitmap(Grp).TransparentColor)
|
||||||
|
else
|
||||||
|
Result := List.Add(TCustomBitmap(Grp), nil);
|
||||||
|
end else
|
||||||
Result := List.AddIcon(Grp as TCustomIcon);
|
Result := List.AddIcon(Grp as TCustomIcon);
|
||||||
finally
|
finally
|
||||||
Grp.Free;
|
Grp.Free;
|
||||||
@ -342,13 +352,24 @@ begin
|
|||||||
try
|
try
|
||||||
Result := Bmp;
|
Result := Bmp;
|
||||||
ANewInstance := True;
|
ANewInstance := True;
|
||||||
{$IFDEF LCLGtk2}
|
if (AImage is TBitmap) and AImage.Transparent then
|
||||||
Bmp.PixelFormat := pf24bit;
|
begin
|
||||||
Bmp.Canvas.Brush.Color := clBtnFace;
|
Bmp.PixelFormat := pf24bit;
|
||||||
{$ELSE}
|
Bmp.Canvas.Brush.Color := TBitmap(AImage).TransparentColor;
|
||||||
Bmp.PixelFormat := pf32bit;
|
Bmp.TransparentColor := TBitmap(AImage).TransparentColor;
|
||||||
Bmp.Canvas.Brush.Color := TColor($FFFFFFFF);
|
Bmp.Transparent := TBitmap(AImage).Transparent;
|
||||||
{$ENDIF}
|
end else
|
||||||
|
begin
|
||||||
|
{$IFDEF LCLGtk2}
|
||||||
|
Bmp.PixelFormat := pf24bit;
|
||||||
|
Bmp.Canvas.Brush.Color := clBtnFace;
|
||||||
|
Bmp.TransparentColor := clBtnFace;
|
||||||
|
Bmp.Transparent := True;
|
||||||
|
{$ELSE}
|
||||||
|
Bmp.PixelFormat := pf32bit;
|
||||||
|
Bmp.Canvas.Brush.Color := TColor($FFFFFFFF);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
Bmp.SetSize(TargetWidth, TargetHeight);
|
Bmp.SetSize(TargetWidth, TargetHeight);
|
||||||
Bmp.Canvas.FillRect(Bmp.Canvas.ClipRect);
|
Bmp.Canvas.FillRect(Bmp.Canvas.ClipRect);
|
||||||
TargetRect := Rect(0, 0, Round(AImage.Width*AFactor), Round(AImage.Height*AFactor));
|
TargetRect := Rect(0, 0, Round(AImage.Width*AFactor), Round(AImage.Height*AFactor));
|
||||||
|
Loading…
Reference in New Issue
Block a user