-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUMBITMAP.PAS
97 lines (79 loc) · 2.1 KB
/
UMBITMAP.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
umbitmap Unit
2022 LRT
}
unit
umbitmap;
interface
uses
consts, utils, uexc, uclasses, types, locale, uobject, ubitmap;
type
PMaskBitmap = ^TMaskBitmap;
TMaskBitmap = object (TBitmap)
public
constructor initWithBitmap(bitmap, mask: PBitmap);
destructor done; virtual;
function getPixel(x, y: word): TColor; virtual;
function getColorCount: longint; virtual;
function getBitsPerPixel: byte; virtual;
procedure setMaskColor(color: TColor);
procedure setTransparentColor(color: TColor);
function getClassName: string; virtual;
function getClassId: word; virtual;
private
_bitmap: PBitmap;
_mask: PBitmap;
_maskColor, _transparentColor: TColor;
end;
implementation
{ TMaskBitmap public }
constructor TMaskBitmap.initWithBitmap(bitmap, mask: PBitmap);
begin
_bitmap := bitmap;
_bitmap^.retain;
_mask := mask;
_mask^.retain;
_maskColor := 1;
_transparentColor := $FF;
inherited initWithSize(_bitmap^.getWidth, _bitmap^.getHeight);
end;
destructor TMaskBitmap.done;
begin
_bitmap^.release;
_mask^.release;
inherited done;
end;
function TMaskBitmap.getPixel(x, y: word): TColor;
begin
if _mask^.getPixel(x, y) = _maskColor then
getPixel := _bitmap^.getPixel(x, y)
else
getPixel := _transparentColor;
end;
function TMaskBitmap.getColorCount: longint;
begin
getColorCount := _bitmap^.getColorCount;
end;
function TMaskBitmap.getBitsPerPixel: byte;
begin
getBitsPerPixel := _bitmap^.getBitsPerPixel;
end;
procedure TMaskBitmap.setMaskColor(color: TColor);
begin
_maskColor := color;
end;
procedure TMaskBitmap.setTransparentColor(color: TColor);
begin
_transparentColor := color;
end;
function TMaskBitmap.getClassName: string;
begin
getClassName := 'TMaskBitmap';
end;
function TMaskBitmap.getClassId: word;
begin
getClassId := C_CLASS_ID_MaskBitmap;
end;
{ TMaskBitmap private }
{ Other }
end.