1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.4 (Public License)
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
// Pascal Port By: Milan Marusinec alias Milano
8
// http://www.aggpas.org
9
// Copyright (c) 2005-2006
11
// Permission to copy, use, modify, sell and distribute this software
12
// is granted provided this copyright notice appears in all copies.
13
// This software is provided "as is" without express or implied
14
// warranty, and with no claim as to its suitability for any purpose.
16
//----------------------------------------------------------------------------
17
// Contact: mcseem@antigrain.com
18
// mcseemagg@yahoo.com
19
// http://www.antigrain.com
21
// [Pascal Port History] -----------------------------------------------------
23
// 23.06.2006-Milano: ptrcomp adjustments
24
// 16.01.2006-Milano: Unit port establishment
41
gamma_lut = object(gamma )
56
m_inv_gamma : int8u_ptr;
58
constructor Construct_(GammaShift : unsigned = 8; HiResShift : unsigned = 8 );
59
constructor Construct (g : double; GammaShift : unsigned = 8; HiResShift : unsigned = 8 );
62
procedure gamma_(g : double );
63
function _gamma : double;
65
function dir(v : unsigned ) : unsigned; virtual;
66
function inv(v : unsigned ) : unsigned; virtual;
74
{ LOCAL VARIABLES & CONSTANTS }
75
{ UNIT IMPLEMENTATION }
77
constructor gamma_lut.Construct_;
82
gamma_shift:=GammaShift;
83
gamma_size :=1 shl gamma_shift;
84
gamma_mask :=gamma_size - 1;
86
hi_res_shift:=HiResShift;
87
hi_res_size :=1 shl hi_res_shift;
88
hi_res_mask :=hi_res_size - 1;
90
HiResT:=hi_res_shift div 8;
91
LoResT:=gamma_shift div 8;
93
agg_getmem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
94
agg_getmem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
97
for i:=0 to gamma_size - 1 do
101
int8u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
102
int8u(i shl (hi_res_shift - gamma_shift ) );
105
int16u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
106
int16u(i shl (hi_res_shift - gamma_shift ) );
109
int32u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
110
int32u(i shl (hi_res_shift - gamma_shift ) );
117
for i:=0 to hi_res_size - 1 do
121
int8u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
122
int8u(i shr (hi_res_shift - gamma_shift ) );
125
int16u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
126
int16u(i shr (hi_res_shift - gamma_shift ) );
129
int32u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
130
int32u(i shr (hi_res_shift - gamma_shift ) );
139
constructor gamma_lut.Construct;
141
gamma_shift:=GammaShift;
142
gamma_size :=1 shl gamma_shift;
143
gamma_mask :=gamma_size - 1;
145
hi_res_shift:=HiResShift;
146
hi_res_size :=1 shl hi_res_shift;
147
hi_res_mask :=hi_res_size - 1;
149
HiResT:=hi_res_shift div 8;
150
LoResT:=gamma_shift div 8;
154
agg_getmem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
155
agg_getmem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
162
destructor gamma_lut.Destruct;
164
agg_freemem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
165
agg_freemem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
170
procedure gamma_lut.gamma_;
180
for i:=0 to gamma_size - 1 do
184
int8u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
185
int8u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
188
int16u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
189
int16u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
192
int32u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
193
int32u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
201
fillchar(m_inv_gamma^ ,hi_res_size * LoResT ,0 )
207
for i:=0 to hi_res_size - 1 do
211
int8u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
212
int8u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
215
int16u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
216
int16u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
219
int32u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
220
int32u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
231
function gamma_lut._gamma : double;
238
function gamma_lut.dir;
242
result:=int8u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
245
result:=int16u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
248
result:=int32u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
258
function gamma_lut.inv;
262
result:=int8u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;
265
result:=int16u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;
268
result:=int32u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;