16 #include <agg_conv_curve.h> 17 #include <agg_conv_stroke.h> 18 #include <agg_pixfmt_rgba.h> 19 #include <agg_rasterizer_scanline_aa.h> 20 #include <agg_renderer_base.h> 21 #include <agg_renderer_scanline.h> 22 #include <agg_scanline_p.h> 28 main (
int argc,
const char* argv[])
32 const int imageWidth = 100;
33 const int imageHeight = 100;
38 const int pixelSize = PixelFormat::pix_width;
42 RendererBaseType rBase;
44 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
47 renderBuffer.attach (imageBuffer, imageWidth, imageHeight, imageWidth * pixelSize);
48 pixFmt.attach(renderBuffer);
51 const agg::rgba8 transparentWhiteColor (0xff, 0xff, 0xff, 0);
52 const agg::rgba8 greenColor (0, 0xff, 0, 0xff);
56 rBase.clear(transparentWhiteColor);
61 ras.auto_close(
false);
65 { agg::path_cmd_move_to, 10, 90 },
66 { agg::path_cmd_curve3, 50, 10 },
67 { agg::path_cmd_curve3, 90, 90 },
80 double strokeWidth = 1.0;
81 strokePath.width(strokeWidth);
82 strokePath.line_cap(agg::square_cap);
83 strokePath.line_join(agg::miter_join);
84 strokePath.miter_limit(strokeWidth);
87 ras.add_path(strokePath);
89 agg::render_scanlines_aa_solid(ras, scanline, rBase, greenColor);
99 double strokeWidth = 2.0;
100 strokePath.width(strokeWidth);
101 strokePath.line_cap(agg::square_cap);
102 strokePath.line_join(agg::miter_join);
103 strokePath.miter_limit(strokeWidth);
106 ras.add_path(strokePath);
108 agg::render_scanlines_aa_solid(ras, scanline, rBase, redColor);
112 char fileName[1000] = { 0 };
115 sprintf (fileName,
"%s/", argv[1]);
117 strcat(fileName,
"tutorial_linedrawing_2.png");
118 writePng<RendererBaseType> (fileName, rBase);
124 printf (
"%s\n", ex.getMessage());
129 printf (
"Unknown exception detected.\n");