16 #include <agg_conv_stroke.h> 17 #include <agg_conv_transform.h> 18 #include <agg_ellipse.h> 19 #include <agg_image_accessors.h> 20 #include <agg_path_storage.h> 21 #include <agg_pixfmt_rgba.h> 22 #include <agg_rasterizer_scanline_aa.h> 23 #include <agg_renderer_base.h> 24 #include <agg_renderer_scanline.h> 25 #include <agg_scanline_p.h> 26 #include <agg_span_allocator.h> 27 #include <agg_span_image_filter_rgba.h> 28 #include <agg_span_interpolator_linear.h> 45 const agg::rgba8 transparentWhiteColor (0xff, 0xff, 0xff, 0);
47 double srcWidth = src.width();
48 double srcHeight = src.height();
53 invertMatrix.invert();
55 InterpolatorType interpolator (invertMatrix);
56 ImageAccessorType ia (src.ren(), transparentWhiteColor);
57 SpanGeneratorType sg (ia, interpolator);
65 agg::render_scanlines_aa(ras, scanline, dst, sa, sg);
69 main (
int argc,
const char* argv[])
73 const int iconWidth = 200;
74 const int iconHeight = 200;
75 const int imageWidth = 800;
76 const int imageHeight = 200;
78 const agg::rgba8 transparentWhiteColor (0xff, 0xff, 0xff, 0);
79 const agg::rgba8 whiteColor (0xff, 0xff, 0xff, 0xff);
82 ras.auto_close(
false);
86 const int pixelSize = PixelFormat::pix_width;
92 const double PI = 3.14159265358979;
94 unsigned char *iconImageBuffer =
new unsigned char[iconWidth * iconHeight * pixelSize];
100 iconRenderBuffer.attach (iconImageBuffer, iconWidth, iconHeight, iconWidth * pixelSize);
101 iconPixFmt.attach(iconRenderBuffer);
102 iconRBase.attach(iconPixFmt);
104 iconRBase.clear(transparentWhiteColor);
110 ras.add_path(circle);
111 agg::render_scanlines_aa_solid(ras, scanline, iconRBase, whiteColor);
124 { 0xfe, 0xfe, 0x33, 0xff },
125 { 0xfb, 0x99, 0x02, 0xff },
126 { 0xfa, 0xbc, 0x02, 0xff },
127 { 0xfe, 0x27, 0x12, 0xff },
128 { 0xfd, 0x53, 0x08, 0xff },
129 { 0x86, 0x01, 0xaf, 0xff },
130 { 0xa7, 0x19, 0x4b, 0xff },
131 { 0x02, 0x47, 0xfe, 0xff },
132 { 0x3d, 0x01, 0xa4, 0xff },
133 { 0x66, 0xb0, 0x32, 0xff },
134 { 0x03, 0x91, 0xce, 0xff },
135 { 0xd0, 0xea, 0x2b, 0xff }
137 SimplePath path (triangle,
sizeof(triangle) /
sizeof(
double));
139 int numRotations =
sizeof(colors) /
sizeof(
agg::rgba8);
140 for (
int i = 0; i < numRotations; ++i)
143 matrix.rotate( PI * 2 * i / numRotations);
144 matrix.translate(100, 100);
150 agg::render_scanlines_aa_solid(ras, scanline, iconRBase, colors[i]);
157 ras.add_path(innerCircle);
158 agg::render_scanlines_aa_solid(ras, scanline, iconRBase, whiteColor);
162 char fileName[1000] = { 0 };
165 sprintf (fileName,
"%s/", argv[1]);
167 strcat(fileName,
"tutorial_image_icon.png");
168 writePng<RendererBaseType> (fileName, iconRBase);
176 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
179 renderBuffer.attach (imageBuffer, imageWidth, imageHeight, imageWidth * pixelSize);
180 pixFmt.attach(renderBuffer);
181 rBase.attach(pixFmt);
183 const agg::rgba8 greenColor (0, 0xff, 0, 0xff);
186 rBase.clear(greenColor);
202 SimplePath rectPath (rect,
sizeof(rect) /
sizeof(
double));
204 drawImage (rBase, iconRBase, matrix, rectPath);
211 path.concat_path(outerRing);
212 path.arrange_orientations(0, agg::path_flags_cw);
216 tmpPath.concat_path(innerRing);
217 tmpPath.arrange_orientations(0, agg::path_flags_ccw);
218 path.concat_path(tmpPath);
224 matrix.translate(200, 0);
226 drawImage (rBase, iconRBase, matrix, tp);
233 matrix.translate(700, 0);
235 drawImage (rBase, iconRBase, matrix, tp);
240 char fileName[1000] = { 0 };
243 sprintf (fileName,
"%s/", argv[1]);
245 strcat(fileName,
"tutorial_image_2.png");
246 writePng<RendererBaseType> (fileName, rBase);
248 delete iconImageBuffer;
253 printf (
"%s\n", ex.getMessage());
258 printf (
"Unknown exception detected.\n");