-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUPALETTE.PAS
92 lines (76 loc) · 1.95 KB
/
UPALETTE.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
{
upalette Unit
Color palette of up to 256 entries, usually included with 256-color bitmaps
2022 LRT
}
unit
upalette;
interface
uses
consts, utils, uexc, uclasses, types, locale, uobject, math;
type
PColorPalette = ^TColorPalette;
TColorPalette = object (TObject)
public
constructor initWithCount(count: word);
destructor done; virtual;
procedure getColors(var colors: PRGBColor; var count: word);
procedure setColor(color: PRGBColor; index: byte);
function getColor(index: byte): PRGBColor;
function getColorCount: word;
function getClassName: string; virtual;
function getClassId: word; virtual;
private
_count: word;
_size: word;
_colors: PRGBColor;
end;
implementation
{ TColorPalette public }
constructor TColorPalette.initWithCount(count: word);
begin
inherited init;
_count := count;
_size := _count * sizeof(TRGBColor);
getMem(_colors, _size);
fillChar(_colors^, _size, 0);
end;
destructor TColorPalette.done;
begin
freeMem(_colors, _size);
inherited done;
end;
procedure TColorPalette.getColors(var colors: PRGBColor; var count: word);
begin
colors := _colors;
count := _count;
end;
procedure TColorPalette.setColor(color: PRGBColor; index: byte);
var p: PRGBColor;
begin
p := _colors;
inc(p, index);
p^ := color^;
end;
function TColorPalette.getColor(index: byte): PRGBColor;
var p: PRGBColor;
begin
p := _colors;
inc(p, index);
getColor := p;
end;
function TColorPalette.getColorCount: word;
begin
getColorCount := _count;
end;
function TColorPalette.getClassName: string;
begin
getClassName := 'TColorPalette';
end;
function TColorPalette.getClassId: word;
begin
getClassId := C_CLASS_ID_ColorPalette;
end;
{ TColorPalette private }
{ Other }
end.