16 #include <agg_conv_stroke.h> 17 #include <agg_pixfmt_rgba.h> 18 #include <agg_rasterizer_scanline_aa.h> 19 #include <agg_renderer_base.h> 20 #include <agg_renderer_scanline.h> 21 #include <agg_scanline_p.h> 35 ras.auto_close(
false);
37 double linePoints[] = { x1, y1, x2, y2 };
38 SimplePath path (linePoints,
sizeof(linePoints) /
sizeof(
double));
41 strokePath.width(lineWidth);
42 strokePath.line_cap(agg::butt_cap);
43 strokePath.line_join(agg::miter_join);
44 strokePath.miter_limit(lineWidth);
47 ras.add_path(strokePath);
49 agg::render_scanlines_aa_solid(ras, scanline, rBase, color);
53 main (
int argc,
const char* argv[])
57 const int imageWidth = 100;
58 const int imageHeight = 25;
60 const int pixelSize = PixelFormat::pix_width;
66 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
69 renderBuffer.attach (imageBuffer, imageWidth, imageHeight, imageWidth * pixelSize);
70 pixFmt.attach(renderBuffer);
73 const agg::rgba8 whiteColor (0xff, 0xff, 0xff, 0xff);
77 rBase.clear(whiteColor);
80 drawLine (rBase, 0, 5, 100, 5, 0.5, blackColor);
81 drawLine (rBase, 0, 8.1, 100, 8.1, 0.5, blackColor);
82 drawLine (rBase, 0, 11.3, 100, 11.3, 0.5, blackColor);
83 drawLine (rBase, 0, 14.5, 100, 14.5, 0.5, blackColor);
84 drawLine (rBase, 0, 17.7, 100, 17.7, 0.5, blackColor);
87 char fileName[1000] = { 0 };
90 sprintf (fileName,
"%s/", argv[1]);
92 strcat(fileName,
"tutorial_linedrawing_4.png");
93 writePng<RendererBaseType> (fileName, rBase);
99 printf (
"%s\n", ex.getMessage());
104 printf (
"Unknown exception detected.\n");