1
//----------------------------------------------------------------------------
2
// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1)
3
// http://milan.marusinec.sk/aggcp
5
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
// http://www.aggpas.org
8
// Contribution Created By:
9
// Milan Marusinec alias Milano
13
// Permission to copy, use, modify, sell and distribute this software
14
// is granted provided this copyright notice appears in all copies.
15
// This software is provided "as is" without express or implied
16
// warranty, and with no claim as to its suitability for any purpose.
18
// [History] -----------------------------------------------------------------
20
// 14.11.2007-Milano: Establishment
22
{ agg_span_gradient_image.pas }
24
agg_span_gradient_image ;
37
agg_rendering_buffer ;
39
{ GLOBAL VARIABLES & CONSTANTS }
42
one_color_function = object(array_base )
45
constructor Construct;
47
function size : unsigned; virtual;
48
function entry : unsigned; virtual;
49
function array_operator(i : unsigned ) : pointer; virtual;
53
gradient_image = object(gradient )
61
m_renbuf : rendering_buffer_ptr;
62
m_pixelf : pixel_formats;
66
m_color_function : one_color_function;
69
constructor Construct;
72
function image_create(width ,height : int ) : pointer;
73
function image_buffer : pointer;
74
function image_width : int;
75
function image_height : int;
76
function image_stride : int;
78
function calculate(x ,y ,d : int ) : int; virtual;
80
function pixel_format : pixel_formats_ptr;
81
function color_function : array_base_ptr;
89
{ LOCAL VARIABLES & CONSTANTS }
90
{ UNIT IMPLEMENTATION }
92
constructor one_color_function.Construct;
99
function one_color_function.size : unsigned;
106
function one_color_function.entry : unsigned;
108
result:=sizeof(aggclr );
113
function one_color_function.array_operator(i : unsigned ) : pointer;
120
constructor gradient_image.Construct;
122
m_color_function.Construct;
132
pixfmt_undefined(m_pixelf );
134
m_color:=m_color_function.array_operator(0 );
139
destructor gradient_image.Destruct;
141
if m_buffer <> NIL then
142
agg_freemem(m_buffer ,m_alocdx * m_alocdy * 4 );
144
if m_renbuf <> NIL then
145
dispose(m_renbuf ,Destruct );
150
function gradient_image.image_create(width ,height : int ) : pointer;
158
if m_renbuf <> NIL then
159
dispose(m_renbuf ,Destruct );
163
if (width > m_alocdx ) or
164
(height > m_alocdy ) then
166
if m_buffer <> NIL then
167
agg_freemem(m_buffer ,m_alocdx * m_alocdy * 4 );
171
if agg_getmem(m_buffer ,width * height * 4 ) then
186
if m_buffer <> NIL then
196
FillChar(row^ ,m_width * 4 ,0 );
198
inc(ptrcomp(row ) ,m_alocdx * 4 );
216
function gradient_image.image_buffer : pointer;
223
function gradient_image.image_width : int;
230
function gradient_image.image_height : int;
237
function gradient_image.image_stride : int;
239
result:=m_alocdx * 4;
244
function gradient_image.calculate(x ,y ,d : int ) : int;
253
if m_buffer <> NIL then
255
px:=shr_int32(x ,gradient_subpixel_shift );
256
py:=shr_int32(y ,gradient_subpixel_shift );
268
pixel:=rgba8_ptr(ptrcomp(m_buffer ) + py * (m_alocdx * 4 ) + px * 4 );
288
function gradient_image.pixel_format : pixel_formats_ptr;
290
if (m_buffer <> NIL ) and
291
(m_renbuf = NIL ) then
293
new(m_renbuf ,Construct );
295
m_renbuf.attach(m_buffer ,m_width ,m_height ,m_alocdx * 4 );
296
pixfmt_rgba32 (m_pixelf ,m_renbuf );
300
if m_renbuf = NIL then
308
function gradient_image.color_function : array_base_ptr;
310
result:=@m_color_function;