-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunitdatamoduleimages.pas
74 lines (58 loc) · 1.51 KB
/
unitdatamoduleimages.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit UnitDataModuleImages;
// Copyright 2022-2025 Zoran Vučenović
// SPDX-License-Identifier: Apache-2.0
{$mode ObjFPC}{$H+}
{$i zxinc.inc}
interface
uses
Classes, SysUtils, Controls, ImgList, Graphics;
type
TDataModuleImages = class(TDataModule)
ImageList1: TImageList;
ImageList2: TImageList;
ImageList3: TImageList;
private
public
function DrawCheckForImage(AIndex: Integer): Integer;
end;
var
DataModuleImages: TDataModuleImages;
implementation
{$R *.lfm}
{ TDataModuleImages }
function TDataModuleImages.DrawCheckForImage(AIndex: Integer): Integer;
var
I: Integer;
L: Integer;
N: Integer;
Ba: array of TCustomBitmap;
B: TBitmap;
R: TRect;
begin
Result := -1;
L := ImageList1.Count;
if (AIndex < L) then begin
N := ImageList1.ResolutionCount;
if N > 0 then begin
SetLength(Ba, N);
try
for I := 0 to N - 1 do begin
B := TBitmap.Create;
ImageList1.ResolutionByIndex[I].GetBitmap(AIndex, B);
R := Rect(B.Width div 2 - 2, B.Height div 2 - 2, B.Width, B.Height);
ImageList3.Resolution[R.Width].StretchDraw(B.Canvas, 0, R);
Ba[I] := B;
end;
Result := ImageList1.AddMultipleResolutions(Ba);
finally
for I := Low(Ba) to High(Ba) do
Ba[I].Free;
end;
end;
end;
end;
initialization
DataModuleImages := TDataModuleImages.Create(nil);
finalization
DataModuleImages.Free;
end.