2
Free Pascal port of the OpenPTC C++ library.
3
Copyright (C) 2001-2003 Nikolay Nikolov (nickysn@users.sourceforge.net)
4
Original C++ version by Glenn Fiedler (ptc@gaffer.org)
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
Constructor TPTCFormat.Create;
30
Fformat.indexed := False;
33
If Not Hermes_Init Then
34
Raise TPTCError.Create('could not initialize hermes');
37
Constructor TPTCFormat.Create(_bits : Integer);
40
{ check bits per pixel }
42
Raise TPTCError.Create('unsupported bits per pixel');
49
Fformat.bits := _bits;
50
Fformat.indexed := True;
53
If Not Hermes_Init Then
54
Raise TPTCError.Create('could not initialize hermes');
57
Constructor TPTCFormat.Create(_bits : Integer; _r, _g, _b, _a : int32);
60
{ check bits per pixel }
61
If ((_bits And 7) <> 0) Or (_bits <= 0) Or (_bits > 32) Then
62
Raise TPTCError.Create('unsupported bits per pixel');
69
Fformat.bits := _bits;
70
Fformat.indexed := False;
73
If Not Hermes_Init Then
74
Raise TPTCError.Create('could not initialize hermes');
77
Constructor TPTCFormat.Create(_bits : Integer; _r, _g, _b : int32);
80
{ check bits per pixel }
81
If ((_bits And 7) <> 0) Or (_bits <= 0) Or (_bits > 32) Then
82
Raise TPTCError.Create('unsupported bits per pixel');
89
Fformat.bits := _bits;
90
Fformat.indexed := False;
93
If Not Hermes_Init Then
94
Raise TPTCError.Create('could not initialize hermes');
97
Constructor TPTCFormat.Create(Const format : TPTCFormat);
100
{ initialize hermes }
101
If Not Hermes_Init Then
102
Raise TPTCError.Create('could not initialize hermes');
104
Hermes_FormatCopy(@format.Fformat, @Fformat)
107
Destructor TPTCFormat.Destroy;
114
Procedure TPTCFormat.Assign(Const format : TPTCFormat);
117
If Self = format Then
118
Raise TPTCError.Create('self assignment is not allowed');
119
Hermes_FormatCopy(@format.Fformat, @Fformat)
122
Function TPTCFormat.Equals(Const format : TPTCFormat) : Boolean;
125
Equals := Hermes_FormatEquals(@format.Fformat, @Fformat);
128
Function TPTCFormat.direct : Boolean;
131
direct := Not Fformat.indexed;
134
Function TPTCFormat.bytes : Integer;
137
bytes := Fformat.bits Shr 3;