17 #include <agg_conv_stroke.h> 18 #include <agg_conv_transform.h> 19 #include <agg_ellipse.h> 20 #include <agg_pixfmt_rgba.h> 21 #include <agg_rasterizer_scanline_aa.h> 22 #include <agg_renderer_base.h> 23 #include <agg_renderer_scanline.h> 24 #include <agg_scanline_p.h> 25 #include <agg_span_allocator.h> 26 #include <agg_span_interpolator_linear.h> 27 #include <agg_span_gradient.h> 36 template<
class SrcPixelFormat>
38 drawIcon(SrcPixelFormat& pixFmt,
int x,
int y,
int width,
int height)
41 SrcPixelFormat dstPixFmt (renBuffer);
42 dstPixFmt.attach (pixFmt, x, y , x + width - 1, y + height - 1);
46 ras.auto_close(
false);
55 double strokeWidth = 10.0;
56 strokePath.width(strokeWidth);
57 strokePath.line_cap(agg::butt_cap);
58 strokePath.line_join(agg::miter_join);
59 strokePath.miter_limit(strokeWidth);
62 ras.add_path(strokePath);
63 const agg::rgba8 purpleColor (0xee, 0, 0xcc, 0xcc);
64 agg::render_scanlines_aa_solid(ras, scanline, rBase, purpleColor);
77 ColorFunctionType> SpanGradientType;
81 GradientFunctionType gradientFunction;
83 matrix.translate (70, 70);
86 invertMatrix.invert();
87 InterpolatorType interpolator (invertMatrix);
89 ColorFunctionType colorFunction (agg::rgba8 (0xff, 0xd7, 0, 0xff),
90 agg::rgba8 (0xff, 0, 0, 0xff),
93 SpanGradientType sg (interpolator, gradientFunction, colorFunction, 0.0, 60.0);
100 agg::render_scanlines_aa(ras, scanline, rBase, sa, sg);
104 template<
class PixFormat,
class BlurType>
106 blurImage(PixFormat& pixFmt,
int x,
int y,
int width,
int height, BlurType& blur,
double radius)
109 PixFormat subPixFmt (renBuffer);
110 subPixFmt.attach (pixFmt, x, y , x + width - 1, y + height - 1);
111 blur.blur (subPixFmt, radius);
115 main (
int argc,
const char* argv[])
119 const int imageWidth = 800;
120 const int imageHeight = 200;
123 ras.auto_close(
false);
127 const int pixelSize = PixelFormat::pix_width;
129 const double PI = 3.14159265358979;
131 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
136 const agg::rgba8 whiteColor (0xff, 0xff, 0xff, 0xff);
137 rBase.clear(whiteColor);
140 drawIcon (pixFmt, 0, 0, 200, 200);
143 drawIcon (pixFmt, 200, 0, 200, 200);
145 blurImage (pixFmt, 200, 0, 200, 200, blur, 10);
149 drawIcon (pixFmt, 400, 0, 200, 200);
151 blurImage (pixFmt, 400, 0, 200, 200, blur, 10);
155 drawIcon (pixFmt, 600 + 5, 0 + 5, 200, 200);
157 blurImage (pixFmt, 600 + 5, 0 + 5, 200, 200, blur, 10);
159 drawIcon (pixFmt, 600, 0, 200, 200);
164 char fileName[1000] = { 0 };
167 sprintf (fileName,
"%s/", argv[1]);
169 strcat(fileName,
"tutorial_blur.png");
170 writePng<RendererBaseType> (fileName, rBase);
176 printf (
"%s\n", ex.getMessage());
181 printf (
"Unknown exception detected.\n");