1
//----------------------------------------------------------------------------
3
// Based on Anti-Grain Geometry
4
// Copyright (C) 2005 Maxim Shemanarev (http://www.antigrain.com)
6
// Agg2D - Version 1.0 Release Milano 3 (AggPas 2.3 RM3)
7
// Pascal Port By: Milan Marusinec alias Milano
9
// http://www.aggpas.org
12
// Permission to copy, use, modify, sell and distribute this software
13
// is granted provided this copyright notice appears in all copies.
14
// This software is provided "as is" without express or implied
15
// warranty, and with no claim as to its suitability for any purpose.
17
//----------------------------------------------------------------------------
18
// Contact: mcseem@antigrain.com
19
// mcseemagg@yahoo.com
20
// http://www.antigrain.com
22
// [Pascal Port History] -----------------------------------------------------
24
// 22.08.2007-Milano: Unit port establishment
25
// 23.08.2007-Milano: Porting
26
// 11.09.2007-Milano: -"-
27
// 13.09.2007-Milano: -"-, Finished OK
37
// With this define uncommented you can use FreeType font engine
38
{ $DEFINE AGG2D_USE_FREETYPE }
49
agg_rendering_buffer ,
51
agg_renderer_scanline ,
53
agg_span_image_filter_rgba ,
54
agg_span_image_resample_rgba ,
56
agg_span_interpolator_linear ,
58
agg_rasterizer_scanline_aa ,
65
agg_font_cache_manager ,
72
agg_render_scanlines ,
74
{$IFDEF AGG2D_USE_FREETYPE }
78
{$IFDEF AGG2D_USE_WINFONTS}
86
{ GLOBAL VARIABLES & CONSTANTS }
89
JoinMiter = miter_join;
90
JoinRound = round_join;
91
JoinBevel = bevel_join;
95
CapSquare = square_cap;
102
AlignTop = AlignRight;
103
AlignBottom = AlignLeft;
106
BlendAlpha = end_of_comp_op_e;
107
BlendClear = comp_op_clear;
108
BlendSrc = comp_op_src;
109
BlendDst = comp_op_dst;
110
BlendSrcOver = comp_op_src_over;
111
BlendDstOver = comp_op_dst_over;
112
BlendSrcIn = comp_op_src_in;
113
BlendDstIn = comp_op_dst_in;
114
BlendSrcOut = comp_op_src_out;
115
BlendDstOut = comp_op_dst_out;
116
BlendSrcAtop = comp_op_src_atop;
117
BlendDstAtop = comp_op_dst_atop;
118
BlendXor = comp_op_xor;
119
BlendAdd = comp_op_plus;
120
BlendSub = comp_op_minus;
121
BlendMultiply = comp_op_multiply;
122
BlendScreen = comp_op_screen;
123
BlendOverlay = comp_op_overlay;
124
BlendDarken = comp_op_darken;
125
BlendLighten = comp_op_lighten;
126
BlendColorDodge = comp_op_color_dodge;
127
BlendColorBurn = comp_op_color_burn;
128
BlendHardLight = comp_op_hard_light;
129
BlendSoftLight = comp_op_soft_light;
130
BlendDifference = comp_op_difference;
131
BlendExclusion = comp_op_exclusion;
132
BlendContrast = comp_op_contrast;
139
Rect_ = agg_basics.rect;
140
RectD = agg_basics.rect_d;
142
Affine = trans_affine;
143
Affine_ptr = trans_affine_ptr;
145
FontRasterizer = gray8_adaptor_type;
146
FontRasterizer_ptr = gray8_adaptor_type_ptr;
148
FontScanline = gray8_scanline_type;
149
FontScanline_ptr = gray8_scanline_type_ptr;
151
{$IFDEF AGG2D_USE_FREETYPE }
152
FontEngine = font_engine_freetype_int32;
155
{$IFDEF AGG2D_USE_WINFONTS}
156
FontEngine = font_engine_win32_tt_int32;
160
Gradient = (Solid ,Linear ,Radial );
161
Direction = (CW, CCW );
165
BlendMode_ = comp_op_e;
208
Transformations_ptr = ^Transformations_;
209
Transformations_ = record
210
affineMatrix : array[0..5 ] of double;
216
renBuf : rendering_buffer;
218
constructor Construct; overload;
219
constructor Construct(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int ); overload;
222
procedure attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
224
function width : int;
225
function height : int;
227
procedure premultiply;
228
procedure demultiply;
232
Agg2DRasterizerGamma = object(vertex_source )
233
m_alpha : gamma_multiply;
234
m_gamma : gamma_power;
236
constructor Construct(alpha ,gamma : double );
238
function func_operator_gamma(x : double ) : double; virtual;
245
m_rbuf : rendering_buffer;
247
m_pixFormat ,m_pixFormatComp ,m_pixFormatPre ,m_pixFormatCompPre : pixel_formats;
248
m_renBase ,m_renBaseComp ,m_renBasePre ,m_renBaseCompPre : renderer_base;
250
m_renSolid ,m_renSolidComp : renderer_scanline_aa_solid;
252
m_allocator : span_allocator;
255
m_blendMode ,m_imageBlendMode : BlendMode_;
257
m_imageBlendColor : Color;
259
m_scanline : scanline_u8;
260
m_rasterizer : rasterizer_scanline_aa;
262
m_masterAlpha ,m_antiAliasGamma : double;
264
m_fillColor ,m_lineColor : Color;
266
m_fillGradient ,m_lineGradient : pod_auto_array;
268
m_lineCap : LineCap_;
269
m_lineJoin : LineJoin_;
271
m_fillGradientFlag ,m_lineGradientFlag : Gradient;
273
m_fillGradientMatrix ,m_lineGradientMatrix : trans_affine;
279
m_textAngle : double;
281
m_textAlignY : TextAlignment;
282
m_textHints : boolean;
285
m_fontDescent : double;
286
m_fontCacheType : FontCacheType;
288
m_imageFilter : ImageFilter_;
289
m_imageResample : ImageResample_;
290
m_imageFilterLut : image_filter_lut;
292
m_fillGradientInterpolator ,
293
m_lineGradientInterpolator : span_interpolator_linear;
295
m_linearGradientFunction : gradient_x;
296
m_radialGradientFunction : gradient_circle;
298
m_lineWidth : double;
299
m_evenOddFlag : boolean;
301
m_path : path_storage;
302
m_transform : trans_affine;
304
m_convCurve : conv_curve;
305
m_convStroke : conv_stroke;
307
m_pathTransform ,m_strokeTransform : conv_transform;
309
{$IFNDEF AGG2D_NO_FONT}
310
m_fontEngine : FontEngine;
311
m_fontCacheManager : font_cache_manager;
313
{$IFDEF AGG2D_USE_WINFONTS }
317
// Other Pascal-specific members
318
m_gammaNone : gamma_none;
319
m_gammaAgg2D : Agg2DRasterizerGamma;
321
m_ifBilinear : image_filter_bilinear;
322
m_ifHanning : image_filter_hanning;
323
m_ifHermite : image_filter_hermite;
324
m_ifQuadric : image_filter_quadric;
325
m_ifBicubic : image_filter_bicubic;
326
m_ifCatrom : image_filter_catrom;
327
m_ifSpline16 : image_filter_spline16;
328
m_ifSpline36 : image_filter_spline36;
329
m_ifBlackman144 : image_filter_blackman144;
332
constructor Construct;
336
procedure attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int ); overload;
337
procedure attach(img : Image_ptr ); overload;
339
procedure clipBox(x1 ,y1 ,x2 ,y2 : double ); overload;
340
function clipBox : RectD; overload;
342
procedure clearAll(c : Color ); overload;
343
procedure clearAll(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
345
procedure clearClipBox(c : Color ); overload;
346
procedure clearClipBox(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
349
procedure worldToScreen(x ,y : double_ptr ); overload;
350
procedure screenToWorld(x ,y : double_ptr ); overload;
351
function worldToScreen(scalar : double ) : double; overload;
352
function screenToWorld(scalar : double ) : double; overload;
354
procedure alignPoint(x ,y : double_ptr );
356
function inBox(worldX ,worldY : double ) : boolean;
358
// General Attributes
359
procedure blendMode(m : BlendMode_ ); overload;
360
function blendMode : BlendMode_; overload;
362
procedure imageBlendMode(m : BlendMode_ ); overload;
363
function imageBlendMode : BlendMode_; overload;
365
procedure imageBlendColor(c : Color ); overload;
366
procedure imageBlendColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
367
function imageBlendColor : Color; overload;
369
procedure masterAlpha(a : double ); overload;
370
function masterAlpha : double; overload;
372
procedure antiAliasGamma(g : double ); overload;
373
function antiAliasGamma : double; overload;
375
procedure fillColor(c : Color ); overload;
376
procedure fillColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
379
procedure lineColor(c : Color ); overload;
380
procedure lineColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
383
function fillColor : Color; overload;
384
function lineColor : Color; overload;
386
procedure fillLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
387
procedure lineLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
389
procedure fillRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 ); overload;
390
procedure lineRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 ); overload;
392
procedure fillRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color ); overload;
393
procedure lineRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color ); overload;
395
procedure fillRadialGradient(x ,y ,r : double ); overload;
396
procedure lineRadialGradient(x ,y ,r : double ); overload;
398
procedure lineWidth (w : double );
399
function lineWidth_(w : double ) : double;
401
procedure lineCap(cap : LineCap_ ); overload;
402
function lineCap : LineCap_; overload;
404
procedure lineJoin(join : LineJoin_ ); overload;
405
function lineJoin : LineJoin_; overload;
407
procedure fillEvenOdd(evenOddFlag : boolean ); overload;
408
function fillEvenOdd : boolean; overload;
411
function transformations : Transformations_; overload;
412
procedure transformations(tr : Transformations_ptr ); overload;
413
procedure resetTransformations;
415
procedure affine(tr : Affine_ptr ); overload;
416
procedure affine(tr : Transformations_ptr ); overload;
418
procedure rotate (angle : double );
419
procedure scale (sx ,sy : double );
420
procedure skew (sx ,sy : double );
421
procedure translate(x ,y : double );
423
procedure parallelogram(x1 ,y1 ,x2 ,y2 : double; para : double_ptr );
426
worldX1 ,worldY1 ,worldX2 ,worldY2 ,
427
screenX1 ,screenY1 ,screenX2 ,screenY2 : double;
428
opt : ViewportOption = XMidYMid );
431
procedure line (x1 ,y1 ,x2 ,y2 : double );
432
procedure triangle (x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
433
procedure rectangle(x1 ,y1 ,x2 ,y2 : double );
435
procedure roundedRect(x1 ,y1 ,x2 ,y2 ,r : double ); overload;
436
procedure roundedRect(x1 ,y1 ,x2 ,y2 ,rx ,ry : double ); overload;
437
procedure roundedRect(
440
rxTop ,ryTop : double ); overload;
442
procedure ellipse(cx ,cy ,rx ,ry : double );
444
procedure arc (cx ,cy ,rx ,ry ,start ,sweep : double );
445
procedure star(cx ,cy ,r1 ,r2 ,startAngle : double; numRays : int );
447
procedure curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double ); overload;
448
procedure curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 ,x4 ,y4 : double ); overload;
450
procedure polygon (xy : double_ptr; numPoints : int );
451
procedure polyline(xy : double_ptr; numPoints : int );
454
procedure flipText(flip : boolean );
457
fileName : char_ptr; height : double;
458
bold : boolean = false;
459
italic : boolean = false;
460
ch : FontCacheType = RasterFontCache;
461
angle : double = 0.0 );
463
function fontHeight : double;
465
procedure textAlignment(alignX ,alignY : TextAlignment );
467
function textHints : boolean; overload;
468
procedure textHints(hints : boolean ); overload;
469
function textWidth(str : char_ptr ) : double;
472
x ,y : double; str : char_ptr;
473
roundOff : boolean = false;
475
ddy : double = 0.0 );
480
procedure moveTo (x ,y : double );
481
procedure moveRel(dx ,dy : double );
483
procedure lineTo (x ,y : double );
484
procedure lineRel(dx ,dy : double );
486
procedure horLineTo (x : double );
487
procedure horLineRel(dx : double );
489
procedure verLineTo (y : double );
490
procedure verLineRel(dy : double );
493
rx ,ry ,angle : double;
494
largeArcFlag ,sweepFlag : boolean;
498
rx ,ry ,angle : double;
499
largeArcFlag ,sweepFlag : boolean;
502
procedure quadricCurveTo (xCtrl ,yCtrl ,xTo ,yTo : double ); overload;
503
procedure quadricCurveRel(dxCtrl ,dyCtrl ,dxTo ,dyTo : double ); overload;
504
procedure quadricCurveTo (xTo ,yTo : double ); overload;
505
procedure quadricCurveRel(dxTo ,dyTo : double ); overload;
507
procedure cubicCurveTo (xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
508
procedure cubicCurveRel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo : double ); overload;
509
procedure cubicCurveTo (xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
510
procedure cubicCurveRel(xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
512
procedure addEllipse(cx ,cy ,rx ,ry : double; dir : Direction );
513
procedure closePolygon;
515
procedure drawPath(flag : DrawPathFlag = FillAndStroke );
517
procedure drawPathNoTransform(flag : DrawPathFlag = FillAndStroke );
519
// Image Transformations
520
procedure imageFilter(f : ImageFilter_ ); overload;
521
function imageFilter : ImageFilter_; overload;
523
procedure imageResample(f : ImageResample_ ); overload;
524
function imageResample : ImageResample_; overload;
526
procedure transformImage(
528
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
529
dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
531
procedure transformImage(
533
dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
535
procedure transformImage(
537
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
538
parallelogram_ : double_ptr ); overload;
540
procedure transformImage(img : Image_ptr; parallelogram_ : double_ptr ); overload;
542
procedure transformImagePath(
544
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
545
dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
547
procedure transformImagePath(
549
dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
551
procedure transformImagePath(
553
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
554
parallelogram_ : double_ptr ); overload;
556
procedure transformImagePath(img : Image_ptr; parallelogram_ : double_ptr ); overload;
558
// Image Blending (no transformations available)
559
procedure blendImage(
561
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
562
dstX ,dstY : double; alpha : unsigned = 255 ); overload;
564
procedure blendImage(img : Image_ptr; dstX ,dstY : double; alpha : unsigned = 255 ); overload;
566
// Copy image directly, together with alpha-channel
569
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
570
dstX ,dstY : double ); overload;
572
procedure copyImage(img : Image_ptr; dstX ,dstY : double ); overload;
575
procedure render(fillColor_ : boolean ); overload;
576
procedure render(ras : FontRasterizer_ptr; sl : FontScanline_ptr ); overload;
578
procedure addLine(x1 ,y1 ,x2 ,y2 : double );
579
procedure updateRasterizerGamma;
580
procedure renderImage(
582
x1 ,y1 ,x2 ,y2 : int;
587
SpanConvImageBlend_ptr = ^SpanConvImageBlend;
588
SpanConvImageBlend = object(span_convertor )
592
m_pixel : pixel_formats_ptr; // m_pixFormatCompPre
595
constructor Construct(m : BlendMode_; c : Color; p : pixel_formats_ptr );
597
procedure convert(span : aggclr_ptr; x ,y : int; len : unsigned ); virtual;
601
{ GLOBAL PROCEDURES }
603
function pi : double;
604
function deg2Rad(v : double ) : double;
605
function rad2Deg(v : double ) : double;
607
function operator_is_equal (c1 ,c2 : Color_ptr ) : boolean;
608
function operator_is_not_equal(c1 ,c2 : Color_ptr ) : boolean;
610
procedure Agg2DRenderer_render(
612
renBase : renderer_base_ptr;
613
renSolid : renderer_scanline_aa_solid_ptr;
614
fillColor_ : boolean ); overload;
616
procedure Agg2DRenderer_render(
618
renBase : renderer_base_ptr;
619
renSolid : renderer_scanline_aa_solid_ptr;
620
ras : gray8_adaptor_type_ptr;
621
sl : gray8_scanline_type_ptr ); overload;
623
procedure Agg2DRenderer_renderImage(
626
renBase : renderer_base_ptr;
627
interpolator : span_interpolator_linear_ptr );
629
function Agg2DUsesFreeType : boolean;
630
function Agg2DUsesWin32TrueType : boolean;
633
{ LOCAL VARIABLES & CONSTANTS }
635
g_approxScale : double = 2.0;
637
{ UNIT IMPLEMENTATION }
639
constructor Image.Construct;
644
constructor Image.Construct(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
646
renBuf.Construct(buf ,width_ ,height_ ,stride );
651
destructor Image.Destruct;
658
procedure Image.attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
660
renBuf.attach(buf ,width_ ,height_ ,stride );
665
function Image.width : int;
667
result:=renBuf._width;
672
function Image.height : int;
674
result:=renBuf._height;
679
procedure Image.premultiply;
681
pixf : pixel_formats;
684
{ pixfmt_rgba32(pixf ,@renBuf );
686
pixf.premultiply; {!}
691
procedure Image.demultiply;
693
pixf : pixel_formats;
696
{ pixfmt_rgba32(pixf ,@renBuf );
703
constructor Agg2DRasterizerGamma.Construct(alpha ,gamma : double );
705
m_alpha.Construct(alpha );
706
m_gamma.Construct(gamma );
710
{ FUNC_OPERATOR_GAMMA }
711
function Agg2DRasterizerGamma.func_operator_gamma(x : double ) : double;
713
result:=m_alpha.func_operator_gamma(m_gamma.func_operator_gamma(x ) );
718
constructor Agg2D.Construct;
722
pixfmt_rgba32 (m_pixFormat ,@m_rbuf );
723
pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order );
724
pixfmt_rgba32 (m_pixFormatPre ,@m_rbuf );
725
pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order );
727
m_renBase.Construct (@m_pixFormat );
728
m_renBaseComp.Construct (@m_pixFormatComp );
729
m_renBasePre.Construct (@m_pixFormatPre );
730
m_renBaseCompPre.Construct(@m_pixFormatCompPre );
732
m_renSolid.Construct (@m_renBase );
733
m_renSolidComp.Construct(@m_renBaseComp );
735
m_allocator.Construct;
736
m_clipBox.Construct(0 ,0 ,0 ,0 );
738
m_blendMode :=BlendAlpha;
739
m_imageBlendMode:=BlendDst;
741
m_imageBlendColor.Construct(0 ,0 ,0 );
743
m_scanline.Construct;
744
m_rasterizer.Construct;
747
m_antiAliasGamma:=1.0;
749
m_fillColor.Construct(255 ,255 ,255 );
750
m_lineColor.Construct(0 ,0 ,0 );
752
m_fillGradient.Construct(256 ,sizeof(aggclr ) );
753
m_lineGradient.Construct(256 ,sizeof(aggclr ) );
755
m_lineCap :=CapRound;
756
m_lineJoin:=JoinRound;
758
m_fillGradientFlag:=Solid;
759
m_lineGradientFlag:=Solid;
761
m_fillGradientMatrix.Construct;
762
m_lineGradientMatrix.Construct;
764
m_fillGradientD1:=0.0;
765
m_lineGradientD1:=0.0;
766
m_fillGradientD2:=100.0;
767
m_lineGradientD2:=100.0;
770
m_textAlignX :=AlignLeft;
771
m_textAlignY :=AlignBottom;
777
m_fontCacheType:=RasterFontCache;
778
m_imageFilter :=Bilinear;
779
m_imageResample:=NoResample;
781
m_gammaNone.Construct;
783
m_ifBilinear.Construct;
784
m_ifHanning.Construct;
785
m_ifHermite.Construct;
786
m_ifQuadric.Construct;
787
m_ifBicubic.Construct;
788
m_ifCatrom.Construct;
789
m_ifSpline16.Construct;
790
m_ifSpline36.Construct;
791
m_ifBlackman144.Construct;
793
m_imageFilterLut.Construct(@m_ifBilinear ,true );
795
m_linearGradientFunction.Construct;
796
m_radialGradientFunction.Construct;
798
m_fillGradientInterpolator.Construct(@m_fillGradientMatrix );
799
m_lineGradientInterpolator.Construct(@m_lineGradientMatrix );
802
m_evenOddFlag:=false;
805
m_transform.Construct;
807
m_convCurve.Construct (@m_path );
808
m_convStroke.Construct(@m_convCurve );
810
m_pathTransform.Construct (@m_convCurve ,@m_transform );
811
m_strokeTransform.Construct(@m_convStroke ,@m_transform );
813
{$IFDEF AGG2D_USE_FREETYPE }
814
m_fontEngine.Construct;
817
{$IFDEF AGG2D_USE_WINFONTS}
821
m_fontEngine.Construct(m_fontDC );
824
{$IFNDEF AGG2D_NO_FONT}
825
m_fontCacheManager.Construct(@m_fontEngine );
829
lineCap (m_lineCap );
830
lineJoin(m_lineJoin );
835
destructor Agg2D.Destruct;
839
m_allocator.Destruct;
842
m_rasterizer.Destruct;
844
m_fillGradient.Destruct;
845
m_lineGradient.Destruct;
847
m_imageFilterLut.Destruct;
850
m_convCurve.Destruct;
851
m_convStroke.Destruct;
853
{$IFNDEF AGG2D_NO_FONT}
854
m_fontEngine.Destruct;
855
m_fontCacheManager.Destruct;
857
{$IFDEF AGG2D_USE_WINFONTS }
858
ReleaseDC(0 ,m_fontDC );
865
procedure Agg2D.attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
867
m_rbuf.attach(buf ,width_ ,height_ ,stride );
869
m_renBase.reset_clipping (true );
870
m_renBaseComp.reset_clipping (true );
871
m_renBasePre.reset_clipping (true );
872
m_renBaseCompPre.reset_clipping(true );
874
resetTransformations;
878
fillColor(255 ,255 ,255 );
880
textAlignment(AlignLeft ,AlignBottom );
882
clipBox (0 ,0 ,width_ ,height_ );
884
lineJoin(JoinRound );
887
imageFilter (Bilinear );
888
imageResample(NoResample );
891
m_antiAliasGamma:=1.0;
893
m_rasterizer.gamma(@m_gammaNone );
895
m_blendMode:=BlendAlpha;
900
procedure Agg2D.attach(img : Image_ptr );
902
attach(img.renBuf._buf ,img.renBuf._width ,img.renBuf._height ,img.renBuf._stride );
907
procedure Agg2D.clipBox(x1 ,y1 ,x2 ,y2 : double );
909
rx1 ,ry1 ,rx2 ,ry2 : int;
912
m_clipBox.Construct(x1 ,y1 ,x2 ,y2 );
919
m_renBase.clip_box_ (rx1 ,ry1 ,rx2 ,ry2 );
920
m_renBaseComp.clip_box_ (rx1 ,ry1 ,rx2 ,ry2 );
921
m_renBasePre.clip_box_ (rx1 ,ry1 ,rx2 ,ry2 );
922
m_renBaseCompPre.clip_box_(rx1 ,ry1 ,rx2 ,ry2 );
924
m_rasterizer.clip_box(x1 ,y1 ,x2 ,y2 );
929
function Agg2D.clipBox : RectD;
936
procedure Agg2D.clearAll(c : Color );
942
m_renBase.clear(@clr );
947
procedure Agg2D.clearAll(r ,g ,b : unsigned; a : unsigned = 255 );
952
clr.Construct(r ,g ,b ,a );
958
procedure Agg2D.clearClipBox(c : Color );
965
m_renBase.copy_bar(0 ,0 ,m_renBase.width ,m_renBase.height ,@clr );
970
procedure Agg2D.clearClipBox(r ,g ,b : unsigned; a : unsigned = 255 );
975
clr.Construct(r ,g ,b ,a );
981
procedure Agg2D.worldToScreen(x ,y : double_ptr );
983
m_transform.transform(@m_transform ,x ,y );
988
procedure Agg2D.screenToWorld(x ,y : double_ptr );
990
m_transform.inverse_transform(@m_transform ,x ,y );
995
function Agg2D.worldToScreen(scalar : double ) : double;
997
x1 ,y1 ,x2 ,y2 : double;
1005
worldToScreen(@x1 ,@y1 );
1006
worldToScreen(@x2 ,@y2 );
1008
result:=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) ) * 0.7071068;
1013
function Agg2D.screenToWorld(scalar : double ) : double;
1015
x1 ,y1 ,x2 ,y2 : double;
1023
screenToWorld(@x1 ,@y1 );
1024
screenToWorld(@x2 ,@y2 );
1026
result:=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) ) * 0.7071068;
1031
procedure Agg2D.alignPoint(x ,y : double_ptr );
1033
worldToScreen(x ,y );
1035
x^:=Floor(x^ ) + 0.5;
1036
y^:=Floor(y^ ) + 0.5;
1038
screenToWorld(x ,y );
1043
function Agg2D.inBox(worldX ,worldY : double ) : boolean;
1045
worldToScreen(@worldX ,@worldY );
1047
result:=m_renBase.inbox(Trunc(worldX ) ,Trunc(worldY ) );
1052
procedure Agg2D.blendMode(m : BlendMode_ );
1056
m_pixFormatComp.comp_op_ (unsigned(m ) );
1057
m_pixFormatCompPre.comp_op_(unsigned(m ) );
1062
function Agg2D.blendMode : BlendMode_;
1064
result:=m_blendMode;
1069
procedure Agg2D.imageBlendMode(m : BlendMode_ );
1071
m_imageBlendMode:=m;
1076
function Agg2D.imageBlendMode : BlendMode_;
1078
result:=m_imageBlendMode;
1083
procedure Agg2D.imageBlendColor(c : Color );
1085
m_imageBlendColor:=c;
1090
procedure Agg2D.imageBlendColor(r ,g ,b : unsigned; a : unsigned = 255 );
1095
clr.Construct (r ,g ,b ,a );
1096
imageBlendColor(clr );
1101
function Agg2D.imageBlendColor : Color;
1103
result:=m_imageBlendColor;
1108
procedure Agg2D.masterAlpha(a : double );
1112
updateRasterizerGamma;
1117
function Agg2D.masterAlpha : double;
1119
result:=m_masterAlpha;
1124
procedure Agg2D.antiAliasGamma(g : double );
1126
m_antiAliasGamma:=g;
1128
updateRasterizerGamma;
1133
function Agg2D.antiAliasGamma : double;
1135
result:=m_antiAliasGamma;
1140
procedure Agg2D.fillColor(c : Color );
1143
m_fillGradientFlag:=Solid;
1148
procedure Agg2D.fillColor(r ,g ,b : unsigned; a : unsigned = 255 );
1153
clr.Construct(r ,g ,b ,a );
1159
procedure Agg2D.noFill;
1164
clr.Construct(0 ,0 ,0 ,0 );
1170
procedure Agg2D.lineColor(c : Color );
1173
m_lineGradientFlag:=Solid;
1178
procedure Agg2D.lineColor(r ,g ,b : unsigned; a : unsigned = 255 );
1183
clr.Construct(r ,g ,b ,a );
1189
procedure Agg2D.noLine;
1194
clr.Construct(0 ,0 ,0 ,0 );
1200
function Agg2D.fillColor : Color;
1202
result:=m_fillColor;
1207
function Agg2D.lineColor : Color;
1209
result:=m_lineColor;
1213
{ FILLLINEARGRADIENT }
1214
procedure Agg2D.fillLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
1216
i ,startGradient ,endGradient : int;
1223
tar : trans_affine_rotation;
1224
tat : trans_affine_translation;
1227
startGradient:=128 - Trunc(profile * 127.0 );
1228
endGradient :=128 + Trunc(profile * 127.0 );
1230
if endGradient <= startGradient then
1231
endGradient:=startGradient + 1;
1233
k:=1.0 / (endGradient - startGradient );
1236
while i < startGradient do
1240
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1245
while i < endGradient do
1247
c:=c1.gradient(c2 ,(i - startGradient ) * k );
1251
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1260
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1265
angle:=ArcTan2(y2 - y1 ,x2 - x1 );
1267
m_fillGradientMatrix.reset;
1269
tar.Construct(angle );
1271
m_fillGradientMatrix.multiply(@tar );
1273
tat.Construct(x1 ,y1 );
1275
m_fillGradientMatrix.multiply(@tat );
1276
m_fillGradientMatrix.multiply(@m_transform );
1277
m_fillGradientMatrix.invert;
1279
m_fillGradientD1 :=0.0;
1280
m_fillGradientD2 :=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) );
1281
m_fillGradientFlag:=Linear;
1283
m_fillColor.Construct(0 ,0 ,0 ); // Set some real color
1287
{ LINELINEARGRADIENT }
1288
procedure Agg2D.lineLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
1290
i ,startGradient ,endGradient : int;
1297
tar : trans_affine_rotation;
1298
tat : trans_affine_translation;
1301
startGradient:=128 - Trunc(profile * 128.0 );
1302
endGradient :=128 + Trunc(profile * 128.0 );
1304
if endGradient <= startGradient then
1305
endGradient:=startGradient + 1;
1307
k:=1.0 / (endGradient - startGradient );
1310
while i < startGradient do
1314
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1319
while i < endGradient do
1321
c:=c1.gradient(c2 ,(i - startGradient) * k );
1325
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1334
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1339
angle:=ArcTan2(y2 - y1 ,x2 - x1 );
1341
m_lineGradientMatrix.reset;
1343
tar.Construct(angle );
1345
m_lineGradientMatrix.multiply(@tar );
1347
tat.Construct(x1 ,y1 );
1349
m_lineGradientMatrix.multiply(@tat );
1350
m_lineGradientMatrix.multiply(@m_transform ); {!}
1351
m_lineGradientMatrix.invert;
1353
m_lineGradientD1 :=0.0;
1354
m_lineGradientD2 :=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) );
1355
m_lineGradientFlag:=Linear;
1357
m_lineColor.Construct(0 ,0 ,0 ); // Set some real color
1361
{ FILLRADIALGRADIENT }
1362
procedure Agg2D.fillRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 );
1364
i ,startGradient ,endGradient : int;
1370
tat : trans_affine_translation;
1373
startGradient:=128 - Trunc(profile * 127.0 );
1374
endGradient :=128 + Trunc(profile * 127.0 );
1376
if endGradient <= startGradient then
1377
endGradient:=startGradient + 1;
1379
k:=1.0 / (endGradient - startGradient );
1382
while i < startGradient do
1386
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1391
while i < endGradient do
1393
c:=c1.gradient(c2 ,(i - startGradient ) * k );
1397
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1406
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1411
m_fillGradientD2:=worldToScreen(r );
1413
worldToScreen(@x ,@y );
1415
m_fillGradientMatrix.reset;
1417
tat.Construct(x ,y );
1419
m_fillGradientMatrix.multiply(@tat );
1420
m_fillGradientMatrix.invert;
1422
m_fillGradientD1 :=0;
1423
m_fillGradientFlag:=Radial;
1425
m_fillColor.Construct(0 ,0 ,0 ); // Set some real color
1429
{ LINERADIALGRADIENT }
1430
procedure Agg2D.lineRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 );
1432
i ,startGradient ,endGradient : int;
1438
tat : trans_affine_translation;
1441
startGradient:=128 - Trunc(profile * 128.0 );
1442
endGradient :=128 + Trunc(profile * 128.0 );
1444
if endGradient <= startGradient then
1445
endGradient:=startGradient + 1;
1447
k:=1.0 / (endGradient - startGradient );
1450
while i < startGradient do
1454
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1459
while i < endGradient do
1461
c:=c1.gradient(c2 ,(i - startGradient ) * k );
1465
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1474
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1479
m_lineGradientD2:=worldToScreen(r );
1481
worldToScreen(@x ,@y );
1483
m_lineGradientMatrix.reset;
1485
tat.Construct(x ,y );
1487
m_lineGradientMatrix.multiply(@tat );
1488
m_lineGradientMatrix.invert;
1490
m_lineGradientD1 :=0;
1491
m_lineGradientFlag:=Radial;
1493
m_lineColor.Construct(0 ,0 ,0 ); // Set some real color
1497
{ FILLRADIALGRADIENT }
1498
procedure Agg2D.fillRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color );
1504
tat : trans_affine_translation;
1511
c:=c1.gradient(c2 ,i / 127.0 );
1515
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1522
c:=c2.gradient(c3 ,(i - 128 ) / 127.0 );
1526
move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1531
m_fillGradientD2:=worldToScreen(r );
1533
worldToScreen(@x ,@y );
1535
m_fillGradientMatrix.reset;
1537
tat.Construct(x ,y );
1539
m_fillGradientMatrix.multiply(@tat );
1540
m_fillGradientMatrix.invert;
1542
m_fillGradientD1 :=0;
1543
m_fillGradientFlag:=Radial;
1545
m_fillColor.Construct(0 ,0 ,0 ); // Set some real color
1549
{ LINERADIALGRADIENT }
1550
procedure Agg2D.lineRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color );
1556
tat : trans_affine_translation;
1563
c:=c1.gradient(c2 ,i / 127.0 );
1567
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1574
c:=c2.gradient(c3 ,(i - 128 ) / 127.0 );
1578
move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1583
m_lineGradientD2:=worldToScreen(r );
1585
worldToScreen(@x ,@y );
1587
m_lineGradientMatrix.reset;
1589
tat.Construct(x ,y );
1591
m_lineGradientMatrix.multiply(@tat );
1592
m_lineGradientMatrix.invert;
1594
m_lineGradientD1 :=0;
1595
m_lineGradientFlag:=Radial;
1597
m_lineColor.Construct(0 ,0 ,0 ); // Set some real color
1601
{ FILLRADIALGRADIENT }
1602
procedure Agg2D.fillRadialGradient(x ,y ,r : double );
1604
tat : trans_affine_translation;
1607
m_fillGradientD2:=worldToScreen(r );
1609
worldToScreen(@x ,@y );
1611
m_fillGradientMatrix.reset;
1613
tat.Construct(x ,y );
1615
m_fillGradientMatrix.multiply(@tat );
1616
m_fillGradientMatrix.invert;
1618
m_fillGradientD1:=0;
1622
{ LINERADIALGRADIENT }
1623
procedure Agg2D.lineRadialGradient(x ,y ,r : double );
1625
tat : trans_affine_translation;
1628
m_lineGradientD2:=worldToScreen(r );
1630
worldToScreen(@x ,@y );
1632
m_lineGradientMatrix.reset;
1634
tat.Construct(x ,y );
1636
m_lineGradientMatrix.multiply(@tat );
1637
m_lineGradientMatrix.invert;
1639
m_lineGradientD1:=0;
1644
procedure Agg2D.lineWidth(w : double );
1648
m_convStroke.width_(w );
1653
function Agg2D.lineWidth_(w : double ) : double;
1655
result:=m_lineWidth;
1660
procedure Agg2D.lineCap(cap : LineCap_ );
1664
m_convStroke.line_cap_(cap );
1669
function Agg2D.lineCap : LineCap_;
1676
procedure Agg2D.lineJoin(join : LineJoin_ );
1680
m_convStroke.line_join_(join );
1685
function Agg2D.lineJoin : LineJoin_;
1692
procedure Agg2D.fillEvenOdd(evenOddFlag : boolean );
1694
m_evenOddFlag:=evenOddFlag;
1697
m_rasterizer.filling_rule(fill_even_odd )
1699
m_rasterizer.filling_rule(fill_non_zero );
1704
function Agg2D.fillEvenOdd : boolean;
1706
result:=m_evenOddFlag;
1711
function Agg2D.transformations : Transformations_;
1713
m_transform.store_to(@result.affineMatrix[0 ] );
1718
procedure Agg2D.transformations(tr : Transformations_ptr );
1720
m_transform.load_from(@tr.affineMatrix[0 ] );
1722
m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1723
m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1727
{ RESETTRANSFORMATIONS }
1728
procedure Agg2D.resetTransformations;
1735
procedure Agg2D.affine(tr : Affine_ptr );
1737
m_transform.multiply(tr );
1739
m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1740
m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1745
procedure Agg2D.affine(tr : Transformations_ptr );
1751
tr.affineMatrix[0 ] ,tr.affineMatrix[1 ] ,tr.affineMatrix[2 ] ,
1752
tr.affineMatrix[3 ] ,tr.affineMatrix[4 ] ,tr.affineMatrix[5 ] );
1754
affine(Affine_ptr(@ta ) );
1759
procedure Agg2D.rotate(angle : double );
1761
tar : trans_affine_rotation;
1764
tar.Construct(angle );
1766
m_transform.multiply(@tar );
1771
procedure Agg2D.scale(sx ,sy : double );
1773
tas : trans_affine_scaling;
1776
tas.Construct(sx ,sy );
1778
m_transform.multiply(@tas );
1780
m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1781
m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1786
procedure Agg2D.skew(sx ,sy : double );
1788
tas : trans_affine_skewing;
1791
tas.Construct(sx ,sy );
1793
m_transform.multiply(@tas );
1798
procedure Agg2D.translate(x ,y : double );
1800
tat : trans_affine_translation;
1803
tat.Construct(x ,y );
1805
m_transform.multiply(@tat );
1810
procedure Agg2D.parallelogram(x1 ,y1 ,x2 ,y2 : double; para : double_ptr );
1815
ta.Construct(x1 ,y1 ,x2 ,y2 ,parallelo_ptr(para ) );
1817
m_transform.multiply(@ta );
1819
m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1820
m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1825
procedure Agg2D.viewport(
1826
worldX1 ,worldY1 ,worldX2 ,worldY2 ,
1827
screenX1 ,screenY1 ,screenX2 ,screenY2 : double;
1828
opt : ViewportOption = XMidYMid );
1830
vp : trans_viewport;
1838
vp.preserve_aspect_ratio(0.0 ,0.0 ,aspect_ratio_stretch );
1841
vp.preserve_aspect_ratio(0.0 ,0.0 ,aspect_ratio_meet );
1844
vp.preserve_aspect_ratio(0.5 ,0.0 ,aspect_ratio_meet );
1847
vp.preserve_aspect_ratio(1.0 ,0.0 ,aspect_ratio_meet );
1850
vp.preserve_aspect_ratio(0.0 ,0.5 ,aspect_ratio_meet );
1853
vp.preserve_aspect_ratio(0.5 ,0.5 ,aspect_ratio_meet );
1856
vp.preserve_aspect_ratio(1.0 ,0.5 ,aspect_ratio_meet );
1859
vp.preserve_aspect_ratio(0.0 ,1.0 ,aspect_ratio_meet );
1862
vp.preserve_aspect_ratio(0.5 ,1.0 ,aspect_ratio_meet );
1865
vp.preserve_aspect_ratio(1.0 ,1.0 ,aspect_ratio_meet );
1869
vp.world_viewport (worldX1 ,worldY1 ,worldX2 ,worldY2 );
1870
vp.device_viewport(screenX1 ,screenY1 ,screenX2 ,screenY2 );
1874
vp.to_affine (@mx );
1875
m_transform.multiply(@mx );
1877
m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1878
m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1883
procedure Agg2D.line(x1 ,y1 ,x2 ,y2 : double );
1887
addLine (x1 ,y1 ,x2 ,y2 );
1888
drawPath(StrokeOnly );
1893
procedure Agg2D.triangle(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
1896
m_path.move_to(x1 ,y1 );
1897
m_path.line_to(x2 ,y2 );
1898
m_path.line_to(x3 ,y3 );
1899
m_path.close_polygon;
1901
drawPath(FillAndStroke );
1906
procedure Agg2D.rectangle(x1 ,y1 ,x2 ,y2 : double );
1909
m_path.move_to(x1 ,y1 );
1910
m_path.line_to(x2 ,y1 );
1911
m_path.line_to(x2 ,y2 );
1912
m_path.line_to(x1 ,y2 );
1913
m_path.close_polygon;
1915
drawPath(FillAndStroke );
1920
procedure Agg2D.roundedRect(x1 ,y1 ,x2 ,y2 ,r : double );
1926
rc.Construct(x1 ,y1 ,x2 ,y2 ,r );
1928
rc.normalize_radius;
1929
rc.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1931
m_path.add_path(@rc ,0 ,false );
1933
drawPath(FillAndStroke );
1938
procedure Agg2D.roundedRect(x1 ,y1 ,x2 ,y2 ,rx ,ry : double );
1946
rc.rect (x1 ,y1 ,x2 ,y2 );
1948
rc.normalize_radius;
1950
m_path.add_path(@rc ,0 ,false );
1952
drawPath(FillAndStroke );
1957
procedure Agg2D.roundedRect(
1959
rxBottom ,ryBottom ,
1960
rxTop ,ryTop : double );
1968
rc.rect (x1 ,y1 ,x2 ,y2 );
1969
rc.radius(rxBottom ,ryBottom ,rxTop ,ryTop );
1970
rc.normalize_radius;
1972
rc.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1974
m_path.add_path(@rc ,0 ,false );
1976
drawPath(FillAndStroke );
1981
procedure Agg2D.ellipse(cx ,cy ,rx ,ry : double );
1988
el.Construct(cx ,cy ,rx ,ry ,0 ,2 * pi );
1990
m_path.add_path(@el ,0 ,false );
1991
m_path.close_polygon;
1993
drawPath(FillAndStroke );
1998
procedure Agg2D.arc(cx ,cy ,rx ,ry ,start ,sweep : double );
2000
ar : {bezier_}agg_arc.arc;
2005
ar.Construct(cx ,cy ,rx ,ry ,start ,sweep ,false );
2007
m_path.add_path(@ar ,0 ,false );
2009
drawPath(StrokeOnly );
2014
procedure Agg2D.star(cx ,cy ,r1 ,r2 ,startAngle : double; numRays : int );
2016
da ,a ,x ,y : double;
2028
while i < numRays do
2030
x:=Cos(a ) * r2 + cx;
2031
y:=Sin(a ) * r2 + cy;
2034
m_path.line_to(x ,y )
2036
m_path.move_to(x ,y );
2040
m_path.line_to(Cos(a ) * r1 + cx ,Sin(a ) * r1 + cy );
2049
drawPath(FillAndStroke );
2054
procedure Agg2D.curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
2057
m_path.move_to(x1 ,y1 );
2058
m_path.curve3 (x2 ,y2 ,x3 ,y3 );
2060
drawPath(StrokeOnly );
2065
procedure Agg2D.curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 ,x4 ,y4 : double );
2068
m_path.move_to(x1 ,y1 );
2069
m_path.curve4 (x2 ,y2 ,x3 ,y3 ,x4 ,y4 );
2071
drawPath(StrokeOnly );
2076
procedure Agg2D.polygon(xy : double_ptr; numPoints : int );
2079
m_path.add_poly(double_2_ptr(xy ) ,numPoints );
2082
drawPath(FillAndStroke );
2087
procedure Agg2D.polyline(xy : double_ptr; numPoints : int );
2090
m_path.add_poly(double_2_ptr(xy ) ,numPoints );
2092
drawPath(StrokeOnly );
2097
procedure Agg2D.flipText(flip : boolean );
2099
{$IFNDEF AGG2D_NO_FONT}
2100
m_fontEngine.flip_y_(flip );
2105
procedure Agg2D.font(
2106
fileName : char_ptr; height : double;
2107
bold : boolean = false;
2108
italic : boolean = false;
2109
ch : FontCacheType = RasterFontCache;
2110
angle : double = 0.0 );
2115
m_textAngle :=angle;
2116
m_fontHeight :=height;
2117
m_fontCacheType:=ch;
2119
{$IFDEF AGG2D_USE_FREETYPE }
2120
if ch = VectorFontCache then
2121
m_fontEngine.load_font(PChar(fileName ) ,0 ,glyph_ren_outline )
2123
m_fontEngine.load_font(PChar(fileName ) ,0 ,glyph_ren_agg_gray8 );
2125
m_fontEngine.hinting_(m_textHints );
2127
if ch = VectorFontCache then
2128
m_fontEngine.height_(height )
2130
m_fontEngine.height_(worldToScreen(height ) );
2133
{$IFDEF AGG2D_USE_WINFONTS}
2135
m_fontEngine.hinting_(m_textHints );
2142
if ch = VectorFontCache then
2143
m_fontEngine.create_font_(PChar(fileName ) ,glyph_ren_outline ,height ,0.0 ,b ,italic )
2145
m_fontEngine.create_font_(PChar(fileName ) ,glyph_ren_agg_gray8 ,worldToScreen(height) ,0.0 ,b ,italic );
2152
function Agg2D.fontHeight : double;
2154
result:=m_fontHeight;
2159
procedure Agg2D.textAlignment(alignX ,alignY : TextAlignment );
2161
m_textAlignX:=alignX;
2162
m_textAlignY:=alignY;
2167
function Agg2D.textHints : boolean;
2169
result:=m_textHints;
2174
procedure Agg2D.textHints(hints : boolean );
2181
function Agg2D.textWidth(str : char_ptr ) : double;
2182
{$IFDEF AGG2D_NO_FONT}
2190
glyph : glyph_cache_ptr;
2200
glyph:=m_fontCacheManager.glyph(int32u(str^ ) );
2202
if glyph <> NIL then
2205
m_fontCacheManager.add_kerning(@x ,@y );
2207
x:=x + glyph.advance_x;
2208
y:=y + glyph.advance_y;
2214
inc(ptrcomp(str ) );
2218
if m_fontCacheType = VectorFontCache then
2221
result:=screenToWorld(x );
2227
procedure Agg2D.text(
2228
x ,y : double; str : char_ptr;
2229
roundOff : boolean = false;
2231
ddy : double = 0.0 );
2232
{$IFDEF AGG2D_NO_FONT}
2238
dx ,dy ,asc ,start_x ,start_y : double;
2240
glyph : glyph_cache_ptr;
2246
tat : trans_affine_translation;
2247
tar : trans_affine_rotation;
2249
tr : conv_transform;
2255
case m_textAlignX of
2257
dx:=-textWidth(str ) * 0.5;
2260
dx:=-textWidth(str );
2265
glyph:=m_fontCacheManager.glyph(int32u('H' ) );
2267
if glyph <> NIL then
2268
asc:=glyph.bounds.y2 - glyph.bounds.y1;
2270
if m_fontCacheType = RasterFontCache then
2271
asc:=screenToWorld(asc );
2273
case m_textAlignY of
2282
if m_fontEngine._flip_y then
2292
start_x:=Trunc(start_x );
2293
start_y:=Trunc(start_y );
2297
start_x:=start_x + ddx;
2298
start_y:=start_y + ddy;
2300
tat.Construct(-x ,-y );
2301
mtx.multiply (@tat );
2303
tar.Construct(m_textAngle );
2304
mtx.multiply (@tar );
2306
tat.Construct(x ,y );
2307
mtx.multiply (@tat );
2309
tr.Construct(m_fontCacheManager.path_adaptor ,@mtx );
2311
if m_fontCacheType = RasterFontCache then
2312
worldToScreen(@start_x ,@start_y );
2316
while char_ptr(ptrcomp(str ) + i * sizeof(char ) )^ <> #0 do
2318
glyph:=m_fontCacheManager.glyph(int32u(char_ptr(ptrcomp(str ) + i * sizeof(char ) )^ ) );
2320
if glyph <> NIL then
2323
m_fontCacheManager.add_kerning(@x ,@y );
2325
m_fontCacheManager.init_embedded_adaptors(glyph ,start_x ,start_y );
2327
if glyph.data_type = glyph_data_outline then
2330
m_path.add_path(@tr ,0 ,false );
2336
if glyph.data_type = glyph_data_gray8 then
2339
m_fontCacheManager.gray8_adaptor ,
2340
m_fontCacheManager.gray8_scanline );
2344
start_x:=start_x + glyph.advance_x;
2345
start_y:=start_y + glyph.advance_y;
2357
procedure Agg2D.resetPath;
2364
procedure Agg2D.moveTo(x ,y : double );
2366
m_path.move_to(x ,y );
2371
procedure Agg2D.moveRel(dx ,dy : double );
2373
m_path.move_rel(dx ,dy );
2378
procedure Agg2D.lineTo(x ,y : double );
2380
m_path.line_to(x ,y );
2385
procedure Agg2D.lineRel(dx ,dy : double );
2387
m_path.line_rel(dx ,dy );
2392
procedure Agg2D.horLineTo(x : double );
2394
m_path.hline_to(x );
2399
procedure Agg2D.horLineRel(dx : double );
2401
m_path.hline_rel(dx );
2406
procedure Agg2D.verLineTo(y : double );
2408
m_path.vline_to(y );
2413
procedure Agg2D.verLineRel(dy : double );
2415
m_path.vline_rel(dy );
2420
procedure Agg2D.arcTo(
2421
rx ,ry ,angle : double;
2422
largeArcFlag ,sweepFlag : boolean;
2425
m_path.arc_to(rx ,ry ,angle ,largeArcFlag ,sweepFlag ,x ,y );
2430
procedure Agg2D.arcRel(
2431
rx ,ry ,angle : double;
2432
largeArcFlag ,sweepFlag : boolean;
2435
m_path.arc_rel(rx ,ry ,angle ,largeArcFlag ,sweepFlag ,dx ,dy );
2440
procedure Agg2D.quadricCurveTo (xCtrl ,yCtrl ,xTo ,yTo : double );
2442
m_path.curve3(xCtrl ,yCtrl ,xTo ,yTo );
2447
procedure Agg2D.quadricCurveRel(dxCtrl ,dyCtrl ,dxTo ,dyTo : double );
2449
m_path.curve3_rel(dxCtrl ,dyCtrl ,dxTo ,dyTo );
2454
procedure Agg2D.quadricCurveTo (xTo ,yTo : double );
2456
m_path.curve3(xTo ,yTo );
2461
procedure Agg2D.quadricCurveRel(dxTo ,dyTo : double );
2463
m_path.curve3_rel(dxTo ,dyTo );
2468
procedure Agg2D.cubicCurveTo (xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2470
m_path.curve4(xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo );
2475
procedure Agg2D.cubicCurveRel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo : double );
2477
m_path.curve4_rel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo );
2482
procedure Agg2D.cubicCurveTo (xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2484
m_path.curve4(xCtrl2 ,yCtrl2 ,xTo ,yTo );
2489
procedure Agg2D.cubicCurveRel(xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2491
m_path.curve4_rel(xCtrl2 ,yCtrl2 ,xTo ,yTo );
2496
procedure Agg2D.addEllipse(cx ,cy ,rx ,ry : double; dir : Direction );
2502
ar.Construct(cx ,cy ,rx ,ry ,0 ,2 * pi )
2504
ar.Construct(cx ,cy ,rx ,ry ,0 ,-2 * pi );
2506
m_path.add_path(@ar ,0 ,false );
2507
m_path.close_polygon;
2512
procedure Agg2D.closePolygon;
2514
m_path.close_polygon;
2519
procedure Agg2D.drawPath(flag : DrawPathFlag = FillAndStroke );
2525
if m_fillColor.a <> 0 then
2527
m_rasterizer.add_path(@m_pathTransform );
2534
if (m_lineColor.a <> 0 ) and
2535
(m_lineWidth > 0.0 ) then
2537
m_rasterizer.add_path(@m_strokeTransform );
2545
if m_fillColor.a <> 0 then
2547
m_rasterizer.add_path(@m_pathTransform );
2553
if (m_lineColor.a <> 0 ) and
2554
(m_lineWidth > 0.0 ) then
2556
m_rasterizer.add_path(@m_strokeTransform );
2565
if m_lineColor.a <> 0 then
2567
m_rasterizer.add_path(@m_pathTransform );
2577
{ DRAWPATHNOTRANSFORM }
2578
procedure Agg2D.drawPathNoTransform(flag : DrawPathFlag = FillAndStroke );
2583
procedure Agg2D.imageFilter(f : ImageFilter_ );
2589
m_imageFilterLut.calculate(@m_ifBilinear ,true );
2592
m_imageFilterLut.calculate(@m_ifHanning ,true );
2595
m_imageFilterLut.calculate(@m_ifHermite ,true );
2598
m_imageFilterLut.calculate(@m_ifQuadric ,true );
2601
m_imageFilterLut.calculate(@m_ifBicubic ,true );
2604
m_imageFilterLut.calculate(@m_ifCatrom ,true );
2607
m_imageFilterLut.calculate(@m_ifSpline16 ,true );
2610
m_imageFilterLut.calculate(@m_ifSpline36 ,true );
2613
m_imageFilterLut.calculate(@m_ifBlackman144 ,true );
2620
function Agg2D.imageFilter : ImageFilter_;
2622
result:=m_imageFilter;
2627
procedure Agg2D.imageResample(f : ImageResample_ );
2634
function Agg2D.imageResample : ImageResample_;
2636
result:=m_imageResample;
2641
procedure Agg2D.transformImage(
2643
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2644
dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2646
parall : array[0..5 ] of double;
2650
moveTo(dstX1 ,dstY1 );
2651
lineTo(dstX2 ,dstY1 );
2652
lineTo(dstX2 ,dstY2 );
2653
lineTo(dstX1 ,dstY2 );
2663
renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,@parall[0 ] );
2668
procedure Agg2D.transformImage(
2670
dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2672
parall : array[0..5 ] of double;
2676
moveTo(dstX1 ,dstY1 );
2677
lineTo(dstX2 ,dstY1 );
2678
lineTo(dstX2 ,dstY2 );
2679
lineTo(dstX1 ,dstY2 );
2689
renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,@parall[0 ] );
2694
procedure Agg2D.transformImage(
2696
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2697
parallelogram_ : double_ptr );
2702
double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ ,
2703
double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ );
2706
double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2707
double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2710
double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ ,
2711
double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ );
2714
double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ +
2715
double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ -
2716
double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2717
double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ +
2718
double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ -
2719
double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2723
renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,parallelogram_ );
2728
procedure Agg2D.transformImage(img : Image_ptr; parallelogram_ : double_ptr );
2733
double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ ,
2734
double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ );
2737
double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2738
double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2741
double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ ,
2742
double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ );
2745
double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ +
2746
double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ -
2747
double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2748
double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ +
2749
double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ -
2750
double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2754
renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,parallelogram_ );
2758
{ TRANSFORMIMAGEPATH }
2759
procedure Agg2D.transformImagePath(
2761
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2762
dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2764
parall : array[0..5 ] of double;
2774
renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,@parall[0 ] );
2778
{ TRANSFORMIMAGEPATH }
2779
procedure Agg2D.transformImagePath(
2781
dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2783
parall : array[0..5 ] of double;
2793
renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,@parall[0 ] );
2797
{ TRANSFORMIMAGEPATH }
2798
procedure Agg2D.transformImagePath(
2800
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2801
parallelogram_ : double_ptr );
2803
renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,parallelogram_ );
2807
{ TRANSFORMIMAGEPATH }
2808
procedure Agg2D.transformImagePath(img : Image_ptr; parallelogram_ : double_ptr );
2810
renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,parallelogram_ );
2815
procedure Agg2D.blendImage(
2817
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2818
dstX ,dstY : double; alpha : unsigned = 255 );
2820
pixF : pixel_formats;
2822
r : agg_basics.rect;
2825
worldToScreen(@dstX ,@dstY );
2826
pixfmt_rgba32(pixF ,@img.renBuf );
2827
r.Construct (imgX1 ,imgY1 ,imgX2 ,imgY2 );
2829
if m_blendMode = BlendAlpha then
2830
m_renBasePre.blend_from(@pixF ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 ,alpha )
2832
m_renBaseCompPre.blend_from(@pixF ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 ,alpha );
2837
procedure Agg2D.blendImage(img : Image_ptr; dstX ,dstY : double; alpha : unsigned = 255 );
2839
pixF : pixel_formats;
2842
worldToScreen(@dstX ,@dstY );
2843
pixfmt_rgba32(pixF ,@img.renBuf );
2845
m_renBasePre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha );
2847
if m_blendMode = BlendAlpha then
2848
m_renBasePre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha )
2850
m_renBaseCompPre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha );
2855
procedure Agg2D.copyImage(
2857
imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2858
dstX ,dstY : double );
2860
r : agg_basics.rect;
2863
worldToScreen(@dstX ,@dstY );
2864
r.Construct (imgX1 ,imgY1 ,imgX2 ,imgY2 );
2866
m_renBase.copy_from(@img.renBuf ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 );
2871
procedure Agg2D.copyImage(img : Image_ptr; dstX ,dstY : double );
2873
worldToScreen(@dstX ,@dstY );
2875
m_renBase.copy_from(@img.renBuf ,NIL ,Trunc(dstX ) ,Trunc(dstY ) );
2880
procedure Agg2D.render(fillColor_ : boolean );
2882
if m_blendMode = BlendAlpha then
2883
Agg2DRenderer_render(@self ,@m_renBase ,@m_renSolid ,fillColor_ )
2885
Agg2DRenderer_render(@self ,@m_renBaseComp ,@m_renSolidComp ,fillColor_ );
2890
procedure Agg2D.render(ras : FontRasterizer_ptr; sl : FontScanline_ptr );
2892
if m_blendMode = BlendAlpha then
2893
Agg2DRenderer_render(@self ,@m_renBase ,@m_renSolid ,ras ,sl )
2895
Agg2DRenderer_render(@self ,@m_renBaseComp ,@m_renSolidComp ,ras ,sl );
2900
procedure Agg2D.addLine(x1 ,y1 ,x2 ,y2 : double );
2902
m_path.move_to(x1 ,y1 );
2903
m_path.line_to(x2 ,y2 );
2907
{ UPDATERASTERIZERGAMMA }
2908
procedure Agg2D.updateRasterizerGamma;
2910
m_gammaAgg2D.Construct(m_masterAlpha ,m_antiAliasGamma );
2911
m_rasterizer.gamma (@m_gammaAgg2D );
2916
procedure Agg2D.renderImage(
2918
x1 ,y1 ,x2 ,y2 : int;
2919
parl : double_ptr );
2923
interpolator : span_interpolator_linear;
2926
mtx.Construct(x1 ,y1 ,x2 ,y2 ,parallelo_ptr(parl ) );
2927
mtx.multiply (@m_transform );
2931
m_rasterizer.add_path(@m_pathTransform );
2933
interpolator.Construct(@mtx );
2935
if m_blendMode = BlendAlpha then
2936
Agg2DRenderer_renderImage(@self ,img ,@m_renBasePre ,@interpolator )
2938
Agg2DRenderer_renderImage(@self ,img ,@m_renBaseCompPre ,@interpolator );
2943
constructor SpanConvImageBlend.Construct(m : BlendMode_; c : Color; p : pixel_formats_ptr );
2952
procedure SpanConvImageBlend.convert(span : aggclr_ptr; x ,y : int; len : unsigned );
2959
if m_mode <> BlendDst then
2962
s2:=Color_ptr(span );
2965
comp_op_adaptor_clip_to_dst_rgba_pre(
2975
inc(ptrcomp(s2 ) ,sizeof(Color ) );
2982
if m_color.a < base_mask then
2985
s2:=Color_ptr(span );
2989
s2.r:=(s2.r * a ) shr base_shift;
2990
s2.g:=(s2.g * a ) shr base_shift;
2991
s2.b:=(s2.b * a ) shr base_shift;
2992
s2.a:=(s2.a * a ) shr base_shift;
2994
inc(ptrcomp(s2 ) ,sizeof(Color ) );
3004
function pi : double;
3006
result:=agg_basics.pi;
3011
function deg2Rad(v : double ) : double;
3013
result:=v * agg_basics.pi / 180.0;
3018
function rad2Deg(v : double ) : double;
3020
result:=v * 180.0 / agg_basics.pi;
3024
{ OPERATOR_IS_EQUAL }
3025
function operator_is_equal(c1 ,c2 : Color_ptr ) : boolean;
3035
{ OPERATOR_IS_NOT_EQUAL }
3036
function operator_is_not_equal(c1 ,c2 : Color_ptr ) : boolean;
3038
result:=not operator_is_equal(c1 ,c2 );
3042
{ AGG2DRENDERER_RENDER }
3043
procedure Agg2DRenderer_render(
3045
renBase : renderer_base_ptr;
3046
renSolid : renderer_scanline_aa_solid_ptr;
3047
fillColor_ : boolean );
3049
span : span_gradient;
3050
ren : renderer_scanline_aa;
3055
(gr.m_fillGradientFlag = Linear ) ) or
3057
(gr.m_lineGradientFlag = Linear ) ) then
3062
@gr.m_fillGradientInterpolator ,
3063
@gr.m_linearGradientFunction ,
3064
@gr.m_fillGradient ,
3065
gr.m_fillGradientD1 ,
3066
gr.m_fillGradientD2 );
3068
ren.Construct (renBase ,@span );
3069
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3076
@gr.m_lineGradientInterpolator ,
3077
@gr.m_linearGradientFunction ,
3078
@gr.m_lineGradient ,
3079
gr.m_lineGradientD1 ,
3080
gr.m_lineGradientD2 );
3082
ren.Construct (renBase ,@span );
3083
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3088
(gr.m_fillGradientFlag = Radial ) ) or
3090
(gr.m_lineGradientFlag = Radial ) ) then
3095
@gr.m_fillGradientInterpolator ,
3096
@gr.m_radialGradientFunction ,
3097
@gr.m_fillGradient ,
3098
gr.m_fillGradientD1 ,
3099
gr.m_fillGradientD2 );
3101
ren.Construct (renBase ,@span );
3102
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3109
@gr.m_lineGradientInterpolator ,
3110
@gr.m_radialGradientFunction ,
3111
@gr.m_lineGradient ,
3112
gr.m_lineGradientD1 ,
3113
gr.m_lineGradientD2 );
3115
ren.Construct (renBase ,@span );
3116
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3122
clr.Construct(gr.m_fillColor )
3124
clr.Construct(gr.m_lineColor );
3126
renSolid.color_ (@clr );
3127
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,renSolid );
3133
{ AGG2DRENDERER_RENDER }
3134
procedure Agg2DRenderer_render(
3136
renBase : renderer_base_ptr;
3137
renSolid : renderer_scanline_aa_solid_ptr;
3138
ras : gray8_adaptor_type_ptr;
3139
sl : gray8_scanline_type_ptr );
3141
span : span_gradient;
3142
ren : renderer_scanline_aa;
3146
if gr.m_fillGradientFlag = Linear then
3150
@gr.m_fillGradientInterpolator ,
3151
@gr.m_linearGradientFunction ,
3152
@gr.m_fillGradient ,
3153
gr.m_fillGradientD1 ,
3154
gr.m_fillGradientD2 );
3156
ren.Construct (renBase ,@span );
3157
render_scanlines(ras ,sl ,@ren );
3161
if gr.m_fillGradientFlag = Radial then
3165
@gr.m_fillGradientInterpolator ,
3166
@gr.m_radialGradientFunction ,
3167
@gr.m_fillGradient ,
3168
gr.m_fillGradientD1 ,
3169
gr.m_fillGradientD2 );
3171
ren.Construct (renBase ,@span );
3172
render_scanlines(ras ,sl ,@ren );
3177
clr.Construct (gr.m_fillColor );
3178
renSolid.color_ (@clr );
3179
render_scanlines(ras ,sl ,renSolid );
3185
{ AGG2DRENDERER_RENDERIMAGE }
3186
procedure Agg2DRenderer_renderImage(
3189
renBase : renderer_base_ptr;
3190
interpolator : span_interpolator_linear_ptr );
3192
blend : SpanConvImageBlend;
3194
si : span_image_filter_rgba;
3195
sg : span_image_filter_rgba_nn;
3196
sb : span_image_filter_rgba_bilinear;
3197
s2 : span_image_filter_rgba_2x2;
3198
sa : span_image_resample_rgba_affine;
3199
sc : span_converter;
3200
ri : renderer_scanline_aa;
3209
blend.Construct(gr.m_imageBlendMode ,gr.m_imageBlendColor ,@gr.m_pixFormatCompPre );
3211
if gr.m_imageFilter = NoFilter then
3213
clr.ConstrInt(0 ,0 ,0 ,0 );
3214
sg.Construct (@gr.m_allocator ,@img.renBuf ,@clr ,interpolator ,rgba_order );
3215
sc.Construct (@sg ,@blend );
3216
ri.Construct (renBase ,@sc );
3218
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3223
resample:=gr.m_imageResample = ResampleAlways;
3225
if gr.m_imageResample = ResampleOnZoomOut then
3227
interpolator._transformer.scaling_abs(@sx ,@sy );
3237
clr.ConstrInt(0 ,0 ,0 ,0 );
3243
@gr.m_imageFilterLut ,
3246
sc.Construct(@sa ,@blend );
3247
ri.Construct(renBase ,@sc );
3249
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3253
if gr.m_imageFilter = Bilinear then
3255
clr.ConstrInt(0 ,0 ,0 ,0 );
3263
sc.Construct(@sb ,@blend );
3264
ri.Construct(renBase ,@sc );
3266
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3270
if gr.m_imageFilterLut.diameter = 2 then
3272
clr.ConstrInt(0 ,0 ,0 ,0 );
3278
@gr.m_imageFilterLut ,
3281
sc.Construct(@s2 ,@blend );
3282
ri.Construct(renBase ,@sc );
3284
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3289
clr.ConstrInt(0 ,0 ,0 ,0 );
3295
@gr.m_imageFilterLut ,
3298
sc.Construct(@si ,@blend );
3299
ri.Construct(renBase ,@sc );
3301
render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3309
{ AGG2DUSESFREETYPE }
3310
function Agg2DUsesFreeType : boolean;
3312
{$IFDEF AGG2D_USE_FREETYPE }
3322
function Agg2DUsesWin32TrueType: boolean;
3324
{$IFDEF AGG2D_USE_WINFONTS }