Using /usr/share/lazarus/1.4RC2/components/aggpas/svg_test.dpr and
/usr/share/lazarus/1.4RC2/components/aggpas/lazarus/example/AggPasInLCLDemo1.lpi
I am trying to draw a simple SVG file.
Here is drawing code
unit Unit1;
//{$mode objfpc}{$H+}
{$mode delphi}
interface
uses
Classes,
//SysUtils,
LCLProc,
FileUtil,
LResources,
Forms, Controls, Graphics,
Dialogs, FPimage, agg_fpimage, Agg_LCL,
//agg_svg_parser_lcl, agg_svg_path_renderer,
agg_basics ,
agg_platform_support ,
agg_color ,
agg_pixfmt ,
agg_pixfmt_rgba ,
agg_ctrl ,
//agg_slider_ctrl ,
agg_rendering_buffer ,
agg_renderer_base ,
agg_renderer_scanline ,
agg_rasterizer_scanline_aa ,
agg_scanline ,
agg_scanline_p ,
agg_render_scanlines ,
agg_trans_affine ,
agg_gamma_functions ,
agg_gsv_text ,
agg_conv_stroke ,
agg_svg_parser_lcl ,
agg_svg_path_renderer,
agg_svg_exception ,
AggPasLCL
;
{$I agg_mode.inc }
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreateOld(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
public
Bitmap1: TBitmap;
procedure Draw0;
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
Draw0;
end;
procedure TForm1.Draw0;
var
AggLCLCanvas: TAggLCLCanvas;
AggSvgLCLParser: parser;
pathRenderer: path_renderer;
begin
AggLCLCanvas:=TAggLCLCanvas.Create;
pathRenderer.Construct;
AggSvgLCLParser.Construct( @pathRenderer );
AggSvgLCLParser.parse('svg/tst.svg');
Bitmap1:=TBitmap.Create;
with AggLCLCanvas do begin
Image.PixelFormat:=afpimRGBA32;
Image.SetSize(120,120);
end;
AggLCLCanvas.Path.m_path.copy_from(@(pathRenderer.m_storage));
AggLCLCanvas.AggDrawPath();
// convert to LCL native pixel format
Bitmap1.LoadFromIntfImage(AggLCLCanvas.Image.IntfImg);
AggSvgLCLParser.Destruct;
AggLCLCanvas.Free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Bitmap1.Free;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Draw(0,0,Bitmap1);
end;
{$R *.lfm}
end.
Here is SVG tst.svg
<?xml version="1.0" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.0"
width="100"
height="100"
id="svg2">
<defs
id="defs4" />
<path
d="M 24.656174,97.865133 L 25.22824,22.932957 C 25.486372,7.7008523 37.691293,2.2784149 50.113172,2.1354538 C 63.512353,1.971473 75.05983,11.844893 74.998102,23.238803 L 74.712067,97.865133 L 24.656174,97.865133 z"
id="path2408"
style="fill:#00ff00;fill-rule:evenodd;stroke:#000000;stroke-width:1.36647499px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
d="M 24.921978,21.840945 C 15.608661,21.812246 15.840123,39.757915 24.993878,39.510016"
id="path2414"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.13771975px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
d="M 24.247024,71.646433 C 14.933707,71.617733 15.165169,89.563402 24.318924,89.315503"
id="path2416"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.13771975px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
d="M 74.642959,39.195771 C 83.954776,39.37676 83.980006,21.429405 74.823775,21.527592"
id="path2418"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.13771975px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
d="M 74.922436,88.959699 C 84.234254,89.140689 84.259483,71.193332 75.103253,71.291519"
id="path2420"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.13771975px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</svg>
Only 1-st path is drawn.
Why?