mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Drawing icons without alpha channel
(cherry picked from commit 6443c5b638)
This commit is contained in:
parent
a2500df30c
commit
179e1a772d
2 changed files with 21 additions and 6 deletions
|
|
@ -549,7 +549,10 @@ begin
|
|||
AIcon.Current:= AIcon.GetBestIndexForSize(TSize.Create(iIconSize, iIconSize));
|
||||
bmStandartBitmap:= Graphics.TBitmap.Create;
|
||||
try
|
||||
BitmapAssign(bmStandartBitmap, AIcon);
|
||||
if AIcon.RawImage.Description.AlphaPrec <> 0 then
|
||||
BitmapAssign(bmStandartBitmap, AIcon)
|
||||
else
|
||||
BitmapConvert(AIcon, bmStandartBitmap);
|
||||
except
|
||||
FreeAndNil(bmStandartBitmap);
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Graphic functions
|
||||
|
||||
Copyright (C) 2013-2019 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2013-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -27,10 +27,11 @@ unit uGraphics;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics, IntfGraphics;
|
||||
Classes, SysUtils, Graphics, IntfGraphics, LCLVersion;
|
||||
|
||||
procedure BitmapConvert(Bitmap: TRasterImage);
|
||||
procedure BitmapAssign(Bitmap, Image: TRasterImage);
|
||||
procedure BitmapConvert(ASource, ATarget: TRasterImage);
|
||||
procedure BitmapAlpha(var ABitmap: TBitmap; APercent: Single);
|
||||
procedure BitmapAssign(Bitmap: TRasterImage; Image: TLazIntfImage);
|
||||
procedure BitmapCenter(var Bitmap: TBitmap; Width, Height: Integer);
|
||||
|
|
@ -44,16 +45,23 @@ type
|
|||
TRawAccess = class(TRasterImage) end;
|
||||
|
||||
procedure BitmapConvert(Bitmap: TRasterImage);
|
||||
begin
|
||||
BitmapConvert(Bitmap, Bitmap);
|
||||
end;
|
||||
|
||||
procedure BitmapConvert(ASource, ATarget: TRasterImage);
|
||||
var
|
||||
Source, Target: TLazIntfImage;
|
||||
begin
|
||||
Source:= TLazIntfImage.Create(Bitmap.RawImage, False);
|
||||
Source:= TLazIntfImage.Create(ASource.RawImage, False);
|
||||
try
|
||||
Target:= TLazIntfImage.Create(Bitmap.Width, Bitmap.Height, [riqfRGB, riqfAlpha]);
|
||||
Target:= TLazIntfImage.Create(ASource.Width, ASource.Height, [riqfRGB, riqfAlpha]);
|
||||
try
|
||||
{$if lcl_fullversion < 2020000}
|
||||
Target.CreateData;
|
||||
{$endif}
|
||||
Target.CopyPixels(Source);
|
||||
BitmapAssign(Bitmap, Target);
|
||||
BitmapAssign(ATarget, Target);
|
||||
finally
|
||||
Target.Free;
|
||||
end;
|
||||
|
|
@ -113,7 +121,9 @@ begin
|
|||
Masked:= ABitmap.RawImage.Description.MaskBitsPerPixel > 0;
|
||||
SrcIntfImage:= TLazIntfImage.Create(ABitmap.RawImage, False);
|
||||
AImage:= TLazIntfImage.Create(ABitmap.Width, ABitmap.Height, [riqfRGB, riqfAlpha]);
|
||||
{$if lcl_fullversion < 2020000}
|
||||
AImage.CreateData;
|
||||
{$endif}
|
||||
for X:= 0 to AImage.Width - 1 do
|
||||
begin
|
||||
for Y:= 0 to AImage.Height - 1 do
|
||||
|
|
@ -144,7 +154,9 @@ begin
|
|||
try
|
||||
Target:= TLazIntfImage.Create(Width, Height, [riqfRGB, riqfAlpha]);
|
||||
try
|
||||
{$if lcl_fullversion < 2020000}
|
||||
Target.CreateData;
|
||||
{$endif}
|
||||
Target.FillPixels(colTransparent);
|
||||
X:= (Width - Bitmap.Width) div 2;
|
||||
Y:= (Height - Bitmap.Height) div 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue