16 #include <agg_conv_curve.h> 17 #include <agg_conv_dash.h> 18 #include <agg_conv_stroke.h> 19 #include <agg_pixfmt_rgba.h> 20 #include <agg_rasterizer_scanline_aa.h> 21 #include <agg_renderer_base.h> 22 #include <agg_renderer_scanline.h> 23 #include <agg_scanline_p.h> 29 main (
int argc,
const char* argv[])
33 const int imageWidth = 400;
34 const int imageHeight = 400;
39 const int pixelSize = PixelFormat::pix_width;
43 RendererBaseType rBase;
45 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
48 renderBuffer.attach (imageBuffer, imageWidth, imageHeight, imageWidth * pixelSize);
49 pixFmt.attach(renderBuffer);
52 const agg::rgba8 transparentWhiteColor (0xff, 0xff, 0xff, 0);
53 const agg::rgba8 greenColor (0, 0xff, 0, 0xff);
57 rBase.clear(transparentWhiteColor);
62 ras.auto_close(
false);
66 { agg::path_cmd_move_to, 50, 350 },
67 { agg::path_cmd_curve3, 200, 50 },
68 { agg::path_cmd_curve3, 350, 350 },
75 double strokeWidth = 5.0;
80 dashPath.add_dash(3 * strokeWidth, 3 * strokeWidth);
82 dashPath.add_dash(1 * strokeWidth, 3 * strokeWidth);
86 strokePath.width(strokeWidth);
87 strokePath.line_cap(agg::butt_cap);
88 strokePath.line_join(agg::miter_join);
89 strokePath.miter_limit(strokeWidth);
92 ras.add_path(strokePath);
94 agg::render_scanlines_aa_solid(ras, scanline, rBase, greenColor);
99 double strokeWidth = 5.0;
107 dashPath.add_dash(3 * strokeWidth, 3 * strokeWidth);
109 dashPath.add_dash(1 * strokeWidth, 3 * strokeWidth);
114 strokePath.width(strokeWidth);
115 strokePath.line_cap(agg::square_cap);
116 strokePath.line_join(agg::miter_join);
117 strokePath.miter_limit(strokeWidth);
120 ras.add_path(strokePath);
122 agg::render_scanlines_aa_solid(ras, scanline, rBase, redColor);
126 char fileName[1000] = { 0 };
129 sprintf (fileName,
"%s/", argv[1]);
131 strcat(fileName,
"tutorial_linedrawing_3.png");
132 writePng<RendererBaseType> (fileName, rBase);
138 printf (
"%s\n", ex.getMessage());
143 printf (
"Unknown exception detected.\n");