mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Load icon with invalid alpha channel
This commit is contained in:
parent
0af34e60ea
commit
c870b38cef
1 changed files with 11 additions and 2 deletions
|
|
@ -30,7 +30,7 @@ function BitmapCreateFromHBITMAP(Handle: HBITMAP): Graphics.TBitmap;
|
|||
implementation
|
||||
|
||||
uses
|
||||
FPImage, GraphType, Forms
|
||||
FPImage, GraphType, Forms, IntfGraphics
|
||||
{$IF DEFINED(LCLQT5)}
|
||||
, SysUtils, LCLProc
|
||||
{$ENDIF}
|
||||
|
|
@ -347,6 +347,7 @@ var
|
|||
Index: Integer;
|
||||
IconInfo: TIconInfo;
|
||||
ARawImage: TRawImage;
|
||||
AImage: TLazIntfImage;
|
||||
begin
|
||||
Result:= Graphics.TBitmap.Create;
|
||||
|
||||
|
|
@ -358,7 +359,7 @@ begin
|
|||
// Check if the bitmap has alpha channel
|
||||
if (ARawImage.Description.BitsPerPixel = 32) and (ScreenInfo.ColorDepth = 32) then
|
||||
begin
|
||||
for Index:= 0 to ARawImage.DataSize - 1 do
|
||||
for Index:= 0 to (ARawImage.DataSize div 4) - 1 do
|
||||
begin
|
||||
if (PLongWord(ARawImage.Data)[Index] shr ARawImage.Description.AlphaShift) and $FF <> 0 then
|
||||
begin
|
||||
|
|
@ -366,6 +367,14 @@ begin
|
|||
Break;
|
||||
end;
|
||||
end;
|
||||
// Invalid alpha channel, use mask instead
|
||||
if ARawImage.Description.AlphaPrec = 0 then
|
||||
begin
|
||||
ARawImage.Description.AlphaPrec:= 8;
|
||||
AImage:= TLazIntfImage.Create(ARawImage, False);
|
||||
AImage.AlphaFromMask(False);
|
||||
AImage.Free;
|
||||
end;
|
||||
end;
|
||||
Result.LoadFromRawImage(ARawImage, True);
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue