mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 01:39:19 +02:00
win32: fix bitmap menu item transparency. Issue #36490. Patch from Denis Kozlov
git-svn-id: trunk@62551 -
This commit is contained in:
parent
e254ce3acb
commit
872fe5d89c
@ -1114,16 +1114,25 @@ var
|
|||||||
AImageList: TCustomImageList;
|
AImageList: TCustomImageList;
|
||||||
FreeImageList: Boolean;
|
FreeImageList: Boolean;
|
||||||
AImageIndex, AImagesWidth: Integer;
|
AImageIndex, AImagesWidth: Integer;
|
||||||
|
ATransparentColor: TColor;
|
||||||
APPI: longint;
|
APPI: longint;
|
||||||
begin
|
begin
|
||||||
AMenuItem.GetImageList(AImageList, AImagesWidth);
|
AMenuItem.GetImageList(AImageList, AImagesWidth);
|
||||||
if (AImageList = nil) or (AMenuItem.ImageIndex < 0) then // using icon from Bitmap
|
if (AImageList = nil) or (AMenuItem.ImageIndex < 0) then // using icon from Bitmap
|
||||||
begin
|
begin
|
||||||
|
if not (Assigned(AMenuItem.Bitmap) and (AMenuItem.Bitmap.Height>0)) then
|
||||||
|
Exit;
|
||||||
AImageList := TImageList.Create(nil);
|
AImageList := TImageList.Create(nil);
|
||||||
AImageList.Width := AMenuItem.Bitmap.Width; // maybe height to prevent too wide bitmaps?
|
AImageList.Width := AMenuItem.Bitmap.Width;
|
||||||
AImageList.Height := AMenuItem.Bitmap.Height;
|
AImageList.Height := AMenuItem.Bitmap.Height;
|
||||||
if not AMenuItem.Bitmap.Transparent then
|
if AMenuItem.Bitmap.Transparent then
|
||||||
AImageIndex := AImageList.AddMasked(AMenuItem.Bitmap, AMenuItem.Bitmap.Canvas.Pixels[0, AImageList.Height-1])
|
begin
|
||||||
|
case AMenuItem.Bitmap.TransparentMode of
|
||||||
|
tmAuto: ATransparentColor := AMenuItem.Bitmap.Canvas.Pixels[0, AImageList.Height-1];
|
||||||
|
tmFixed: ATransparentColor := AMenuItem.Bitmap.TransparentColor;
|
||||||
|
end;
|
||||||
|
AImageIndex := AImageList.AddMasked(AMenuItem.Bitmap, ATransparentColor);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
AImageIndex := AImageList.Add(AMenuItem.Bitmap, nil);
|
AImageIndex := AImageList.Add(AMenuItem.Bitmap, nil);
|
||||||
FreeImageList := True;
|
FreeImageList := True;
|
||||||
|
Loading…
Reference in New Issue
Block a user