mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 10:39:18 +02:00
LCL: TLCLGlyphs: fix loading images. Issue #33826
git-svn-id: trunk@58131 -
This commit is contained in:
parent
c560db1304
commit
8c5aa34fba
@ -298,6 +298,7 @@ type
|
|||||||
const ACanvasScaleFactor: Double): TScaledImageListResolution;
|
const ACanvasScaleFactor: Double): TScaledImageListResolution;
|
||||||
function GetWidthForPPI(AImageWidth, APPI: Integer): Integer;
|
function GetWidthForPPI(AImageWidth, APPI: Integer): Integer;
|
||||||
function GetHeightForPPI(AImageWidth, APPI: Integer): Integer;
|
function GetHeightForPPI(AImageWidth, APPI: Integer): Integer;
|
||||||
|
function GetHeightForWidth(AWidth: Integer): Integer;
|
||||||
function GetCount: Integer;
|
function GetCount: Integer;
|
||||||
function GetSizeForPPI(AImageWidth, APPI: Integer): TSize;
|
function GetSizeForPPI(AImageWidth, APPI: Integer): TSize;
|
||||||
function GetBestIconIndexForSize(AIcon: TCustomIcon; AWidth: Integer): Integer; // the icon must be sorted
|
function GetBestIconIndexForSize(AIcon: TCustomIcon; AWidth: Integer): Integer; // the icon must be sorted
|
||||||
@ -400,6 +401,7 @@ type
|
|||||||
property DrawingStyle: TDrawingStyle read FDrawingStyle write SetDrawingStyle default dsNormal;
|
property DrawingStyle: TDrawingStyle read FDrawingStyle write SetDrawingStyle default dsNormal;
|
||||||
property Height: Integer read FHeight write SetHeight default 16;
|
property Height: Integer read FHeight write SetHeight default 16;
|
||||||
property HeightForPPI[AImageWidth, APPI: Integer]: Integer read GetHeightForPPI;
|
property HeightForPPI[AImageWidth, APPI: Integer]: Integer read GetHeightForPPI;
|
||||||
|
property HeightForWidth[AWidth: Integer]: Integer read GetHeightForWidth;
|
||||||
property Width: Integer read FWidth write SetWidth default 16;
|
property Width: Integer read FWidth write SetWidth default 16;
|
||||||
property WidthForPPI[AImageWidth, APPI: Integer]: Integer read GetWidthForPPI;
|
property WidthForPPI[AImageWidth, APPI: Integer]: Integer read GetWidthForPPI;
|
||||||
property SizeForPPI[AImageWidth, APPI: Integer]: TSize read GetSizeForPPI;
|
property SizeForPPI[AImageWidth, APPI: Integer]: TSize read GetSizeForPPI;
|
||||||
|
@ -1183,7 +1183,7 @@ begin
|
|||||||
Result.FImageList := FImageList;
|
Result.FImageList := FImageList;
|
||||||
Result.FWidth := AImageWidth;
|
Result.FWidth := AImageWidth;
|
||||||
if FImageList.Width<>0 then
|
if FImageList.Width<>0 then
|
||||||
Result.FHeight := FImageList.Height * AImageWidth div FImageList.Width
|
Result.FHeight := FImageList.GetHeightForWidth(AImageWidth)
|
||||||
else
|
else
|
||||||
Result.FHeight := 0;
|
Result.FHeight := 0;
|
||||||
Result.FAutoCreatedInDesignTime := AutoCreatedInDesignTime and (AImageWidth<>FImageList.Width);
|
Result.FAutoCreatedInDesignTime := AutoCreatedInDesignTime and (AImageWidth<>FImageList.Width);
|
||||||
@ -1804,12 +1804,15 @@ begin
|
|||||||
if FData.Find(AImageWidth, I) then
|
if FData.Find(AImageWidth, I) then
|
||||||
Result := FData[I].Height
|
Result := FData[I].Height
|
||||||
else
|
else
|
||||||
begin
|
Result := GetHeightForWidth(AImageWidth)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomImageList.GetHeightForWidth(AWidth: Integer): Integer;
|
||||||
|
begin
|
||||||
if FWidth<>0 then
|
if FWidth<>0 then
|
||||||
Result := AImageWidth * FHeight div FWidth
|
Result := AWidth * FHeight div FWidth
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomImageList.GetIcon(Index: Integer; Image: TIcon; AEffect: TGraphicsDrawEffect);
|
procedure TCustomImageList.GetIcon(Index: Integer; Image: TIcon; AEffect: TGraphicsDrawEffect);
|
||||||
@ -2724,12 +2727,15 @@ function TLCLGlyphs.GetImageIndex(const AResourceName: string): Integer;
|
|||||||
function AddNewBtnImage(Resolution: TResolution): Integer;
|
function AddNewBtnImage(Resolution: TResolution): Integer;
|
||||||
var
|
var
|
||||||
G: TCustomBitmap;
|
G: TCustomBitmap;
|
||||||
|
ImageRect: TRect;
|
||||||
begin
|
begin
|
||||||
G := GetDefaultGlyph(AResourceName, Resolution.ScaleSuffix, True);
|
G := GetDefaultGlyph(AResourceName, Resolution.ScaleSuffix, True);
|
||||||
if G=nil then
|
if G=nil then
|
||||||
Exit(-1);
|
Exit(-1);
|
||||||
try
|
try
|
||||||
Result := AddSliceCentered(G);
|
ImageRect := Rect(0, 0, Resolution.Width, GetHeightForWidth(Resolution.Width));
|
||||||
|
OffsetRect(ImageRect, (G.Width-ImageRect.Right) div 2, (G.Height-ImageRect.Bottom) div 2);
|
||||||
|
Result := AddSlice(G, ImageRect);
|
||||||
finally
|
finally
|
||||||
G.Free;
|
G.Free;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user