16 #include <agg_pixfmt_rgba.h> 17 #include <agg_renderer_base.h> 22 main (
int argc,
const char* argv[])
26 const int imageWidth = 100;
27 const int imageHeight = 100;
32 const int pixelSize = PixelFormat::pix_width;
36 RendererBaseType rBase;
38 unsigned char *imageBuffer =
new unsigned char[imageWidth * imageHeight * pixelSize];
41 renderBuffer.attach (imageBuffer, imageWidth, imageHeight, imageWidth * pixelSize);
42 pixFmt.attach(renderBuffer);
45 const agg::rgba8 transparentWhiteColor (0xff, 0xff, 0xff, 0);
46 const agg::rgba8 greenColor (0, 0xff, 0, 0xff);
49 rBase.clear(transparentWhiteColor);
56 for (
int x = 0; x < imageWidth; ++x)
58 rBase.copy_pixel(x, 0, greenColor);
61 for (
int x = 0; x < imageWidth; ++x)
63 rBase.copy_pixel(x, imageHeight - 1, greenColor);
66 for (
int y = 0; y < imageHeight; ++y)
68 rBase.copy_pixel(0, y, greenColor);
71 for (
int y = 0; y < imageHeight; ++y)
73 rBase.copy_pixel(imageWidth - 1, y, greenColor);
77 char fileName[1000] = { 0 };
80 sprintf (fileName,
"%s/", argv[1]);
82 strcat(fileName,
"tutorial_rendererbase.png");
83 writePng<RendererBaseType> (fileName, rBase);
89 printf (
"%s\n", ex.getMessage());
94 printf (
"Unknown exception detected.\n");