27 #include "../annotationtext/Attributes.h"
28 #include "../annotationtext/Element.h"
29 #include "../annotationtext/Text.h"
30 #include "../common/StringUtils.h"
31 #include "../geometry/Coord2D.h"
32 #include "../geometry/Geometry.h"
33 #include "../geometry/GeometryCollection.h"
34 #include "../geometry/LineString.h"
35 #include "../geometry/LinearRing.h"
36 #include "../geometry/MultiLineString.h"
37 #include "../geometry/MultiPoint.h"
38 #include "../geometry/MultiPolygon.h"
39 #include "../geometry/Point.h"
40 #include "../geometry/PointM.h"
41 #include "../geometry/PointZ.h"
42 #include "../geometry/PointZM.h"
43 #include "../geometry/Polygon.h"
44 #include "../postgis/EWKBReader.h"
45 #include "../postgis/Utils.h"
47 #include "../common/FileDirUtils.h"
52 #include <agg_renderer_markers.h>
54 #include <agg_conv_transform.h>
55 #include <agg_conv_stroke.h>
56 #include <agg_renderer_scanline.h>
57 #include <agg_image_accessors.h>
58 #include <agg_span_pattern_rgb.h>
59 #include <agg_span_allocator.h>
60 #include <agg_conv_smooth_poly1.h>
61 #include <agg_pattern_filters_rgba.h>
62 #include <agg_renderer_outline_image.h>
63 #include <agg_renderer_outline_aa.h>
64 #include <agg_rasterizer_outline_aa.h>
65 #include <agg_span_interpolator_linear.h>
66 #include <agg_span_image_filter_rgba.h>
67 #include <agg_trans_single_path.h>
84 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
85 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
86 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
87 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
88 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
89 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
90 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
91 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
92 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
93 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254,
94 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
95 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
96 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
97 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
98 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
99 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
100 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
101 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
102 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
103 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
104 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
105 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
106 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
107 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, 253,
108 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 252,
109 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 251, 251, 251, 251, 251,
110 251, 251, 251, 251, 250, 250, 250, 250, 250, 250, 250, 250, 249, 249, 249, 249,
111 249, 249, 249, 248, 248, 248, 248, 248, 248, 248, 247, 247, 247, 247, 247, 246,
112 246, 246, 246, 246, 246, 245, 245, 245, 245, 245, 244, 244, 244, 244, 243, 243,
113 243, 243, 243, 242, 242, 242, 242, 241, 241, 241, 241, 240, 240, 240, 239, 239,
114 239, 239, 238, 238, 238, 238, 237, 237, 237, 236, 236, 236, 235, 235, 235, 234,
115 234, 234, 233, 233, 233, 232, 232, 232, 231, 231, 230, 230, 230, 229, 229, 229,
116 228, 228, 227, 227, 227, 226, 226, 225, 225, 224, 224, 224, 223, 223, 222, 222,
117 221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 215, 214, 214,
118 213, 213, 212, 212, 211, 211, 210, 210, 209, 209, 208, 207, 207, 206, 206, 205,
119 204, 204, 203, 203, 202, 201, 201, 200, 200, 199, 198, 198, 197, 196, 196, 195,
120 194, 194, 193, 192, 192, 191, 190, 190, 189, 188, 188, 187, 186, 186, 185, 184,
121 183, 183, 182, 181, 180, 180, 179, 178, 177, 177, 176, 175, 174, 174, 173, 172,
122 171, 171, 170, 169, 168, 167, 166, 166, 165, 164, 163, 162, 162, 161, 160, 159,
123 158, 157, 156, 156, 155, 154, 153, 152, 151, 150, 149, 148, 148, 147, 146, 145,
124 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129,
125 128, 128, 127, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113,
126 112, 111, 110, 109, 108, 107, 106, 105, 104, 102, 101, 100, 99, 98, 97, 96,
127 95, 94, 93, 91, 90, 89, 88, 87, 86, 85, 84, 82, 81, 80, 79, 78,
128 77, 75, 74, 73, 72, 71, 70, 69, 67, 66, 65, 64, 63, 61, 60, 59,
129 58, 57, 56, 54, 53, 52, 51, 50, 48, 47, 46, 45, 44, 42, 41, 40,
130 39, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 20,
131 19, 18, 17, 15, 14, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1
142 agg::rgba8
pixel(
int x,
int y)
const
144 agg::rgba8 c =
m_pf.pixel(x, y);
164 m_fontManager =
new agg::font_cache_manager<agg::font_engine_win32_tt_int16>(*m_fontEngine);
165 m_fontEngine->create_font(
"Verdana", agg::glyph_ren_outline);
166 m_fontEngine->height(16.);
204 delete m_fontManager;
206 ::ReleaseDC(0, m_hdc);
210 delete m_polyPatternBuffer;
211 delete m_contourPatternBuffer;
212 delete m_linePatternBuffer;
213 delete m_ptPatternBuffer;
217 const double& urx,
const double& ury)
224 double xScale =
static_cast<double>(m_dwidth) / (urx - llx);
225 double yScale =
static_cast<double>(m_dheight) / (ury - lly);
228 m_matrix *= agg::trans_affine_translation(-m_wllx, -m_wlly);
229 m_matrix *= agg::trans_affine_scaling(xScale, yScale);
233 const HAlignType& ha,
const VAlignType& va)
235 double ww = urx - llx;
236 double wh = ury - lly;
237 double widthByHeight = (double)getWidth()/(double)getHeight();
238 if(widthByHeight > ww/wh)
241 ww = wh * widthByHeight;
249 llx = llx - (ww - v) / 2.;
256 wh = ww / widthByHeight;
264 lly = lly - (wh - v) / 2.;
268 setWindow(llx, lly, urx, ury);
283 m_rendererBase.clear(m_bgColor);
293 m_buffer =
new unsigned char[m_dwidth * m_dheight *
DEPTH/8];
294 memset(m_buffer, 255, m_dwidth * m_dheight *
DEPTH/8);
295 m_renderingBuffer = agg::rendering_buffer(m_buffer, m_dwidth, m_dheight, -m_dwidth *
DEPTH/8);
296 m_pixfmt =
new pixfmt(m_renderingBuffer);
297 m_rendererBase = agg::renderer_base<pixfmt>(*m_pixfmt);
304 unsigned int wkbGeomType = *((
unsigned int*)(geom + 1));
313 return drawMultiPolygon(geom);
316 return drawPolygon(geom);
319 return drawPoint(geom);
322 return drawMultiLineString(geom);
325 return drawMultiPoint(geom);
328 return drawLineString(geom);
331 return drawPointZ(geom);
334 return drawPointM(geom);
337 return drawPointZM(geom);
340 return drawGeometryCollection(geom);
353 double x = *((
double*)(point + 5));
354 double y = *((
double*)(point + 13));
356 m_matrix.transform(&x, &y);
357 if(m_ptPatternBuffer == 0)
359 agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(m_rendererBase);
360 m_rendMarker.fill_color(m_ptColor);
361 m_rendMarker.line_color(m_ptColor);
362 m_rendMarker.marker((
int)x, (
int)y, m_ptWidth/2, m_ptMarkerType);
369 pixfmt pixf_img(m_ptPatternRenderingBuffer);
372 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
374 int w = m_ptWidth / 2;
375 int h = m_ptPatternRenderingBuffer.height() * m_ptWidth / m_ptPatternRenderingBuffer.width() / 2;
376 m_rasterizer.reset();
377 m_rasterizer.move_to_d(x-w, y-h);
378 m_rasterizer.line_to_d(x+w, y-h);
379 m_rasterizer.line_to_d(x+w, y+h);
380 m_rasterizer.line_to_d(x-w, y+h);
382 typedef agg::span_allocator<color_type> span_alloc_type;
384 agg::image_filter_bilinear filter_kernel;
385 agg::image_filter_lut filter(filter_kernel,
true);
387 typedef agg::image_accessor_clone<pixfmt> source_type;
388 source_type source(pixf_img);
390 agg::trans_affine tr;
391 tr.translate(-(x-w), -(y-h));
392 double scale = (double)pixf_img.width() / (double)m_ptWidth;
393 tr.scale(scale, scale);
395 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
396 interpolator_type interpolator(tr);
398 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
399 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
409 point = drawPoint(point);
416 point = drawPoint(point);
423 point = drawPoint(point);
436 const unsigned int nPts = *((
unsigned int*)(mpoint));
440 for(
register unsigned int i = 0; i != nPts; ++i)
441 mpoint = drawPoint(mpoint);
452 const unsigned int nPoints = *((
unsigned int*)(line + 5));
454 assert(nPoints >= 2);
459 size_t size = nPoints*2;
460 double* v =
new double[size];
465 for(
register unsigned int i = 0; i != nPoints; ++i)
467 v[j++] = coords[i].
x;
468 v[j++] = coords[i].
y;
471 drawLineString(v, size);
473 line += 16 * nPoints;
485 const unsigned int nLines = *((
unsigned int*)(mline));
489 for(
register unsigned int i = 0; i != nLines; ++i)
490 mline = drawLineString(mline);
501 const unsigned int nRings = *((
unsigned int*)(poly + 5));
505 agg::path_storage path;
506 int pathIndex = path.start_new_path();
509 char* ptr = poly + 9;
511 for(
register unsigned int i = 0; i != nRings; ++i)
513 const unsigned int nPoints = *((
unsigned int*)ptr);
519 double* v =
new double[nPoints*2];
520 memcpy(v, (
double*)ptr, 16 * nPoints);
522 ptr += (16 * nPoints);
524 path.concat_poly(v, nPoints,
true);
528 drawPolygon(path, pathIndex);
540 const unsigned int nPolygons = *((
unsigned int*)mpoly);
542 assert(nPolygons > 0);
546 for(
unsigned int i = 0; i != nPolygons; ++i)
547 mpoly = drawPolygon(mpoly);
559 const unsigned int nGeoms = *((
unsigned int*)g);
565 for(
register unsigned int i = 0; i != nGeoms; ++i)
579 draw(static_cast<te::gm::MultiPolygon*>(geom));
586 draw(static_cast<te::gm::Point*>(geom));
593 draw(static_cast<te::gm::LineString*>(geom));
600 draw(static_cast<te::gm::Polygon*>(geom));
607 draw(static_cast<te::gm::MultiLineString*>(geom));
614 draw(static_cast<te::gm::MultiPoint*>(geom));
621 draw(static_cast<te::gm::GeometryCollection*>(geom));
631 double x = point->
getX();
632 double y = point->
getY();
634 m_matrix.transform(&x, &y);
635 if(m_ptPatternBuffer == 0)
637 agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(m_rendererBase);
638 m_rendMarker.fill_color(m_ptColor);
639 m_rendMarker.line_color(m_ptColor);
640 m_rendMarker.marker((
int)x, (
int)y, m_ptWidth/2, m_ptMarkerType);
644 pixfmt pixf_img(m_ptPatternRenderingBuffer);
647 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
649 int w = m_ptWidth / 2;
650 int h = m_ptPatternRenderingBuffer.height() * m_ptWidth / m_ptPatternRenderingBuffer.width() / 2;
651 m_rasterizer.reset();
652 m_rasterizer.move_to_d(x-w, y-h);
653 m_rasterizer.line_to_d(x+w, y-h);
654 m_rasterizer.line_to_d(x+w, y+h);
655 m_rasterizer.line_to_d(x-w, y+h);
657 typedef agg::span_allocator<color_type> span_alloc_type;
659 agg::image_filter_bilinear filter_kernel;
660 agg::image_filter_lut filter(filter_kernel,
true);
662 typedef agg::image_accessor_clone<pixfmt> source_type;
663 source_type source(pixf_img);
665 agg::trans_affine tr;
666 tr.translate(-(x-w), -(y-h));
667 double scale = (double)pixf_img.width() / (double)m_ptWidth;
668 tr.scale(scale, scale);
670 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
671 interpolator_type interpolator(tr);
673 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
674 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
701 for(
size_t i = 0; i < size; ++i)
702 draw(static_cast<te::gm::Point*>(mpoint->
getGeometryN(i)));
707 for(
size_t i = 0; i < size; ++i)
708 draw(static_cast<te::gm::PointZ*>(mpoint->
getGeometryN(i)));
713 for(
size_t i = 0; i < size; ++i)
714 draw(static_cast<te::gm::PointM*>(mpoint->
getGeometryN(i)));
719 for(
size_t i = 0; i < size; ++i)
720 draw(static_cast<te::gm::PointZM*>(mpoint->
getGeometryN(i)));
733 double* v =
new double[size*2];
736 for(
register size_t i = 0; i != size; ++i)
738 v[j++] = coords[i].
x;
739 v[j++] = coords[i].
y;
742 drawLineString(v, size);
747 if(m_linePatternBuffer == 0)
749 agg::path_storage path;
750 int pathIndex = path.start_new_path();
751 path.concat_poly(v, size,
false);
754 m_rasterizer.gamma(agg::gamma_threshold(.4));
756 agg::conv_transform<agg::path_storage> fill(path, m_matrix);
757 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
759 stroke.width(m_lineWidth);
760 m_rasterizer.add_path(stroke, pathIndex);
761 agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_lineColor);
769 agg::pattern_filter_bilinear_rgba8 fltr;
778 typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
779 typedef agg::renderer_base<pixfmt> base_ren_type;
780 typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
781 typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
783 typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
784 typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
787 pattern_type patt(fltr);
789 renderer_img_type ren_img(m_rendererBase, patt);
790 rasterizer_img_type ras_img(ren_img);
793 agg::line_profile_aa profile;
794 profile.smoother_width(p1.
height());
795 profile.width(p1.
height()-4);
796 renderer_line_type ren_line(m_rendererBase, profile);
797 ren_line.color(agg::rgba8(200,200,200));
798 rasterizer_line_type ras_line(ren_line);
803 ren_img.start_x(p1.
width()/2.);
805 agg::poly_plain_adaptor<double> vs(v, size,
false);
806 agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs, m_matrix);
807 ras_line.add_path(trans);
808 ras_img.add_path(trans);
818 for(
size_t i = 0; i < size; ++i)
819 draw(static_cast<te::gm::LineString*>(mline->
getGeometryN(i)));
828 agg::path_storage path;
829 int pathIndex = path.start_new_path();
831 for(
register size_t i = 0; i != nRings; ++i)
839 double* v =
new double[nPoints*2];
842 path.concat_poly(v, nPoints,
true);
846 drawPolygon(path, pathIndex);
851 agg::conv_transform<agg::path_storage> transPath(path, m_matrix);
853 if(m_polyPatternBuffer == 0)
855 m_rasterizer.gamma(agg::gamma_threshold(.4));
856 m_rasterizer.filling_rule(agg::fill_even_odd);
858 m_rasterizer.add_path(transPath, index);
859 agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_polyFillColor);
863 if(m_polyPatternWidth != m_polyPatternRenderingBuffer.width())
865 int width = m_polyPatternWidth;
866 int height = m_polyPatternRenderingBuffer.height() * m_polyPatternWidth / m_polyPatternRenderingBuffer.width();
867 agg::int8u* buf =
new agg::int8u[width * height *
DEPTH/8];
868 memset(buf, 0, width * height *
DEPTH/8);
869 agg::rendering_buffer rbuf(buf, width, height, -width *
DEPTH/8);
871 pixfmt pixf_img(m_polyPatternRenderingBuffer);
873 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
875 m_rasterizer.reset();
876 m_rasterizer.move_to_d(0, 0);
877 m_rasterizer.line_to_d(width, 0);
878 m_rasterizer.line_to_d(width-1, height-1);
879 m_rasterizer.line_to_d(0, height-1);
881 typedef agg::span_allocator<color_type> span_alloc_type;
883 agg::image_filter_bilinear filter_kernel;
884 agg::image_filter_lut filter(filter_kernel,
true);
886 typedef agg::image_accessor_clone<pixfmt> source_type;
887 source_type source(pixf_img);
889 agg::trans_affine tr;
890 double scale = (double)pixf_img.width() / (double)width;
891 tr.scale(scale, scale);
893 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
894 interpolator_type interpolator(tr);
896 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
897 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
898 delete m_polyPatternBuffer;
899 m_polyPatternBuffer = buf;
900 m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, width, height, -width *
DEPTH/8);
905 agg::renderer_base<pixfmt_pre> rb_pre(*pixf_pre);
907 typedef agg::wrap_mode_repeat_auto_pow2 repeat_x_type;
908 typedef agg::wrap_mode_repeat_auto_pow2 repeat_y_type;
909 typedef agg::image_accessor_wrap<pixfmt, repeat_x_type, repeat_y_type> img_source_type;
910 typedef agg::span_pattern_rgb<img_source_type> span_gen_type;
912 agg::span_allocator<color_type> sa;
913 pixfmt img_pixf(m_polyPatternRenderingBuffer);
914 img_source_type img_src(img_pixf);
915 span_gen_type sg(img_src, 0, 0);
918 sg.alpha(span_gen_type::value_type(m_polyPatternOpacity));
920 m_rasterizer.add_path(transPath);
921 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
924 if(m_contourPatternBuffer == 0)
926 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(transPath);
927 stroke.width(m_polyContourWidth);
928 m_rasterizer.add_path(stroke, index);
929 agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_polyContourColor);
935 agg::pattern_filter_bilinear_rgba8 fltr;
944 typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
945 typedef agg::renderer_base<pixfmt> base_ren_type;
946 typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
947 typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
949 typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
950 typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
953 pattern_type patt(fltr);
955 renderer_img_type ren_img(m_rendererBase, patt);
956 rasterizer_img_type ras_img(ren_img);
959 agg::line_profile_aa profile;
960 profile.smoother_width(p1.
height());
961 profile.width(p1.
height()-4);
962 renderer_line_type ren_line(m_rendererBase, profile);
963 ren_line.color(agg::rgba8(200,200,200));
964 rasterizer_line_type ras_line(ren_line);
969 ren_img.start_x(p1.
width()/2.);
975 int size = path.total_vertices();
977 for(k = i = 0; i < size; ++i)
979 if(path.vertex(i, &x, &y) != 79)
983 v =
new double[(k+1)<<1];
987 path.vertex(j, &x, &y);
995 agg::poly_plain_adaptor<double> vs(v, k+1,
false);
996 agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs, m_matrix);
997 ras_line.add_path(trans);
998 ras_img.add_path(trans);
1011 for(
size_t i = 0; i < size; ++i)
1012 draw(static_cast<te::gm::Polygon*>(mpoly->
getGeometryN(i)));
1019 for(
size_t i = 0; i < size; ++i)
1090 agg::int8u* buf =
new agg::int8u[h * w *
DEPTH/8];
1091 for(i = 0; i < h; ++i)
1094 for(j = 0; j < w; ++j)
1098 buf[n] = (agg::int8u)c.
getRed();
1099 buf[n + 1] = (agg::int8u)c.
getGreen();
1100 buf[n + 2] = (agg::int8u)c.
getBlue();
1101 buf[n + 3] = (agg::int8u)c.
getAlpha();
1104 agg::rendering_buffer rbuf(buf, w, h, -w *
DEPTH/8);
1108 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1110 typedef agg::span_allocator<color_type> span_alloc_type;
1112 agg::image_filter_bilinear filter_kernel;
1113 agg::image_filter_lut filter(filter_kernel,
true);
1115 typedef agg::image_accessor_clone<pixfmt> source_type;
1116 source_type source(pixf_img);
1118 agg::trans_affine tr;
1119 int ty = m_dheight - rbuf.height();
1120 tr.translate(0, -ty);
1122 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1123 interpolator_type interpolator(tr);
1125 m_rasterizer.reset();
1126 m_rasterizer.move_to_d(0, ty);
1127 m_rasterizer.line_to_d(w, ty);
1128 m_rasterizer.line_to_d(w, ty + rbuf.height());
1129 m_rasterizer.line_to_d(0, ty + rbuf.height());
1131 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1132 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1150 agg::int8u* buf =
new agg::int8u[h * w *
DEPTH/8];
1151 for(i = 0; i < h; ++i)
1154 for(j = 0; j < w; ++j)
1158 buf[n] = (agg::int8u)c.
getRed();
1159 buf[n + 1] = (agg::int8u)c.
getGreen();
1160 buf[n + 2] = (agg::int8u)c.
getBlue();
1161 buf[n + 3] = (agg::int8u)c.
getAlpha();
1164 agg::rendering_buffer rbuf(buf, w, h, -w *
DEPTH/8);
1168 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1170 typedef agg::span_allocator<color_type> span_alloc_type;
1172 agg::image_filter_bilinear filter_kernel;
1173 agg::image_filter_lut filter(filter_kernel,
true);
1175 typedef agg::image_accessor_clone<pixfmt> source_type;
1176 source_type source(pixf_img);
1178 agg::trans_affine tr;
1179 int ty = m_dheight - rbuf.height() -y;
1180 tr.translate(-x, -ty);
1182 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1183 interpolator_type interpolator(tr);
1185 m_rasterizer.reset();
1186 m_rasterizer.move_to_d(x, ty);
1187 m_rasterizer.line_to_d(x+w, ty);
1188 m_rasterizer.line_to_d(x+w, ty + rbuf.height());
1189 m_rasterizer.line_to_d(x, ty + rbuf.height());
1191 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1192 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1210 agg::int8u* buf =
new agg::int8u[srch * srcw *
DEPTH/8];
1211 for(i = 0; i < srch; ++i)
1214 for(j = 0; j < srcw; ++j)
1218 buf[n] = (agg::int8u)c.
getRed();
1219 buf[n + 1] = (agg::int8u)c.
getGreen();
1220 buf[n + 2] = (agg::int8u)c.
getBlue();
1221 buf[n + 3] = (agg::int8u)c.
getAlpha();
1224 agg::rendering_buffer rbuf(buf, srcw, srch, -srcw *
DEPTH/8);
1228 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1230 typedef agg::span_allocator<color_type> span_alloc_type;
1232 agg::image_filter_bilinear filter_kernel;
1233 agg::image_filter_lut filter(filter_kernel,
true);
1235 typedef agg::image_accessor_clone<pixfmt> source_type;
1236 source_type source(pixf_img);
1238 agg::trans_affine tr;
1239 double xscale = (double)pixf_img.width() / (double)w;
1240 double yscale = (double)pixf_img.height() / (double)h;
1241 int nh = (int)((
double)(rbuf.height())/yscale + .5);
1242 int ty = m_dheight - nh - y;
1243 tr.translate(-x, -ty);
1244 tr.scale(xscale, yscale);
1246 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1247 interpolator_type interpolator(tr);
1249 m_rasterizer.reset();
1250 m_rasterizer.move_to_d(x, ty);
1251 m_rasterizer.line_to_d(x+w, ty);
1252 m_rasterizer.line_to_d(x+w, ty+h);
1253 m_rasterizer.line_to_d(x, ty+h);
1255 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1256 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1260 void te::ag::Canvas::drawImage(
int x,
int y,
int w,
int h,
char* src,
int size,
te::map::Canvas::ImageType t,
int sx,
int sy,
int sw,
int sh)
1274 agg::int8u* buf =
new agg::int8u[sh * sw *
DEPTH/8];
1275 for(i = sy; i < sh; ++i)
1277 k = (i - sy) * 4 * sw;
1278 for(j = sx; j < sw; ++j)
1281 n = k + 4 * (j - sx);
1282 buf[n] = (agg::int8u)c.
getRed();
1283 buf[n + 1] = (agg::int8u)c.
getGreen();
1284 buf[n + 2] = (agg::int8u)c.
getBlue();
1285 buf[n + 3] = (agg::int8u)c.
getAlpha();
1288 agg::rendering_buffer rbuf(buf, sw, sh, -sw *
DEPTH/8);
1292 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1294 typedef agg::span_allocator<color_type> span_alloc_type;
1296 agg::image_filter_bilinear filter_kernel;
1297 agg::image_filter_lut filter(filter_kernel,
true);
1299 typedef agg::image_accessor_clone<pixfmt> source_type;
1300 source_type source(pixf_img);
1302 agg::trans_affine tr;
1303 double xscale = (double)pixf_img.width() / (double)w;
1304 double yscale = (double)pixf_img.height() / (double)h;
1305 int nh = (int)((
double)(rbuf.height())/yscale + .5);
1306 int ty = m_dheight - nh - y;
1307 tr.translate(-x, -ty);
1308 tr.scale(xscale, yscale);
1310 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1311 interpolator_type interpolator(tr);
1313 m_rasterizer.reset();
1314 m_rasterizer.move_to_d(x, ty);
1315 m_rasterizer.line_to_d(x+w, ty);
1316 m_rasterizer.line_to_d(x+w, ty+h);
1317 m_rasterizer.line_to_d(x, ty+h);
1319 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1320 agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1325 int yy = m_dheight - y - 1;
1326 m_rendererBase.blend_pixel(x, yy, m_ptColor, agg::cover_full);
1331 int yy = m_dheight - y - 1;
1333 m_rendererBase.blend_pixel(x, yy, cor, agg::cover_full);
1337 const std::string& tx,
1342 agg::trans_affine matrix;
1343 matrix.scale(m_txXScale, 1.);
1344 m_fontEngine->transform(matrix);
1347 const char* p = tx.c_str();
1351 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1354 m_fontManager->add_kerning(&xa, &ya);
1355 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1358 xa += glyph->advance_x;
1359 ya += glyph->advance_y;
1363 double txWidth = xa;
1368 matrix.translate(-xi, -yi);
1369 matrix.rotate(-angle *
PI / 180.);
1370 matrix.translate(xi, yi);
1373 xi = x + txWidth / 2.;
1378 yi = y + m_fontEngine->height();
1380 yi = y + m_fontEngine->height() * 3. /8.;
1382 yi = y - m_fontEngine->height() / 4.;
1384 matrix.transform(&xi, &yi);
1387 double xx = x - (xi - x);
1388 double yy = m_dheight - yi;
1389 double xf = xx + (m_dwidth<<2);
1392 matrix.translate(-xx, -yy);
1393 matrix.scale(m_txXScale, 1.);
1394 matrix.rotate(-angle *
PI / 180.);
1395 matrix.translate(xx, yy);
1396 matrix.transform(&xf, &yf);
1398 agg::path_storage path;
1399 int pathIndex = path.start_new_path();
1400 path.move_to(xx, yy);
1401 path.line_to(xf, yf);
1403 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1405 agg::trans_single_path tcurve;
1406 tcurve.add_path(path);
1407 tcurve.preserve_x_scale(
true);
1413 fsegm.approximation_scale(3.0);
1414 fcurves.approximation_scale(2.0);
1422 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1425 if(xa > tcurve.total_length())
1428 m_fontManager->add_kerning(&xa, &ya);
1429 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1431 if(glyph->data_type == agg::glyph_data_outline)
1433 m_rasterizer.reset();
1434 m_rasterizer.add_path(ftrans);
1435 rendererSolid.color(m_txColor);
1436 agg::render_scanlines(m_rasterizer, m_scanline, rendererSolid);
1440 xa += glyph->advance_x;
1441 ya += glyph->advance_y;
1448 if(m_txDecorationType > 0)
1451 matrix.translate(-xx, -yy);
1452 matrix.rotate(-angle *
PI / 180.);
1453 matrix.translate(xx, yy);
1456 yf = yy + ya + m_fontEngine->height();
1457 yy -= m_fontEngine->height()/4.;
1459 if(m_txDecorationType == 1)
1460 yy += m_fontEngine->height()/4.;
1461 else if(m_txDecorationType == 2)
1462 yy += m_fontEngine->height() + m_fontEngine->height()/4.;
1463 else if(m_txDecorationType == 3)
1464 yy += (m_fontEngine->height() + m_fontEngine->height()/4.) / 2.;
1466 pathIndex = path.start_new_path();
1470 matrix.transform(&a, &b);
1474 matrix.transform(&a, &b);
1476 path.close_polygon(
false);
1478 m_rasterizer.gamma(agg::gamma_threshold(.4));
1479 agg::conv_transform<agg::path_storage> fill(path, matrix);
1480 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1481 stroke.width(m_txDecorationWidth);
1482 m_rasterizer.add_path(stroke, pathIndex);
1483 agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_txDecorationColor);
1499 if(matrix.is_identity() ==
false)
1501 v =
new double[size<<1];
1508 matrix.transform(&x, &y);
1509 v[i++] = (int)(x+.5);
1510 v[i++] = (int)(y+.5);
1513 distx += abs((
int)(v[i-2] - v[i-4]));
1514 disty += abs((
int)(v[i-1] - v[i-3]));
1523 if(distx == 0 && disty == 0)
1535 distx += abs((
int)(v[i-2] - v[i-4]));
1536 disty += abs((
int)(v[i-1] - v[i-3]));
1541 int len = (int)tx.size() * fontSize/2;
1542 int dist = (int)sqrt((
double)(distx * distx + disty * disty));
1549 agg::path_storage path;
1550 path.start_new_path();
1552 path.concat_poly(v, size,
false);
1555 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1557 agg::trans_single_path tcurve;
1558 tcurve.add_path(path);
1559 tcurve.preserve_x_scale(
true);
1565 fsegm.approximation_scale(3.0);
1566 fcurves.approximation_scale(2.0);
1568 m_fontEngine->height(fontSize);
1571 std::string font = m_fontEngine->font_signature();
1572 if(font.find(
"Californian FB") == std::string::npos)
1573 b = m_fontEngine->create_font(
"Californian FB", agg::glyph_ren_outline);
1577 double x = (double)dist/2. - (
double)len/2.;
1579 const char* p = tx.c_str();
1583 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1586 if(x > tcurve.total_length())
1589 m_fontManager->add_kerning(&x, &y);
1590 m_fontManager->init_embedded_adaptors(glyph, x, y);
1592 if(glyph->data_type == agg::glyph_data_outline)
1594 m_rasterizer.reset();
1595 m_rasterizer.add_path(ftrans);
1596 rendererSolid.color(agg::rgba8(0, 0, 0));
1597 agg::render_scanlines(m_rasterizer, m_scanline, rendererSolid);
1601 x += glyph->advance_x;
1602 y += glyph->advance_y;
1612 const std::string& tx,
1617 double x = wp.
getX();
1618 double y = wp.
getY();
1620 m_matrix.transform(&x, &y);
1621 drawText((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1625 const std::string& tx,
1633 m_matrix.transform(&x, &y);
1634 drawText((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1644 while(tx->
getElements()[i]->getAttributes() == 0 && i < size)
1659 setFontFamily(family);
1663 setTextPointSize(pointSize);
1667 setTextWeight(weight);
1671 setTextStyle(style);
1677 setTextUnderline(
false);
1678 setTextOverline(
false);
1679 setTextStrikeOut(
false);
1682 setTextOverline(
true);
1684 setTextUnderline(
true);
1686 setTextStrikeOut(
true);
1700 setTextOpacity(opacity);
1732 std::string text = element->
getValue();
1733 size_t p = text.find(
"\n");
1736 if(p != std::string::npos)
1741 hline *= m_textLineSpacing;
1746 while(p != std::string::npos)
1748 std::string t = text.substr(0, p);
1749 drawText(*pclone, t, 0., hAlign, vAlign);
1750 text = text.substr(p+1);
1751 p = text.find(
"\n");
1752 pclone->
setY(pclone->
getY() - hline);
1755 drawText(*pclone, text, 0., hAlign, vAlign);
1757 drawText(*pt, text, 0., hAlign, vAlign);
1769 agg::trans_affine matrix;
1770 matrix.scale(m_txXScale, 1.);
1771 m_fontEngine->transform(matrix);
1774 const char* p = tx.c_str();
1778 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1781 m_fontManager->add_kerning(&xa, &ya);
1782 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1785 xa += glyph->advance_x;
1786 ya += glyph->advance_y;
1790 double txWidth = xa;
1795 matrix.translate(-xi, -yi);
1796 matrix.rotate(-angle *
PI / 180.);
1797 matrix.translate(xi, yi);
1800 xi = x + txWidth / 2.;
1805 yi = y + m_fontEngine->height();
1807 yi = y + m_fontEngine->height() * 3. /8.;
1809 yi = y - m_fontEngine->height() / 4.;
1811 matrix.transform(&xi, &yi);
1814 double xx = x - (xi - x);
1815 double yy = m_dheight - yi;
1816 double xf = xx + (m_dwidth<<2);
1819 matrix.translate(-xx, -yy);
1820 matrix.scale(m_txXScale, 1.);
1821 matrix.rotate(-angle *
PI / 180.);
1822 matrix.translate(xx, yy);
1823 matrix.transform(&xf, &yf);
1825 agg::path_storage path;
1826 int pathIndex = path.start_new_path();
1827 path.move_to(xx, yy);
1828 path.line_to(xf, yf);
1830 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1832 agg::trans_single_path tcurve;
1833 tcurve.add_path(path);
1834 tcurve.preserve_x_scale(
true);
1840 fsegm.approximation_scale(3.0);
1841 fcurves.approximation_scale(2.0);
1849 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1852 m_fontManager->add_kerning(&xa, &ya);
1853 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1856 xa += glyph->advance_x;
1857 ya += glyph->advance_y;
1866 matrix.translate(-xx, -yy);
1867 matrix.rotate(-angle *
PI / 180.);
1868 matrix.translate(xx, yy);
1871 yf = yy + ya + m_fontEngine->height();
1872 yy -= m_fontEngine->height()/4.;
1875 pathIndex = path.start_new_path();
1879 matrix.transform(&a, &b);
1883 matrix.transform(&a, &b);
1887 matrix.transform(&a, &b);
1891 matrix.transform(&a, &b);
1893 path.close_polygon(
true);
1896 m_rasterizer.gamma(agg::gamma_threshold(.4));
1897 agg::conv_transform<agg::path_storage> fill(path, matrix);
1898 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1899 stroke.width(m_txBoundaryWidth);
1900 m_rasterizer.add_path(stroke, pathIndex);
1901 agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_txBoundaryColor);
1909 double x = wp.
getX();
1910 double y = wp.
getY();
1912 m_matrix.transform(&x, &y);
1913 drawTextBoundary((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1921 m_matrix.transform(&x, &y);
1922 drawTextBoundary((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1927 agg::trans_affine matrix;
1928 matrix.scale(m_txXScale, 1.);
1932 const char* p = tx.c_str();
1936 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1939 m_fontManager->add_kerning(&xa, &ya);
1940 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1943 xa += glyph->advance_x;
1944 ya += glyph->advance_y;
1948 double txWidth = xa;
1953 matrix.translate(-xi, -yi);
1954 matrix.rotate(-angle *
PI / 180.);
1955 matrix.translate(xi, yi);
1958 xi = x + txWidth / 2.;
1963 yi = y + m_fontEngine->height();
1965 yi = y + m_fontEngine->height() * 3. /8.;
1967 yi = y - m_fontEngine->height() / 4.;
1969 matrix.transform(&xi, &yi);
1972 double xx = x - (xi - x);
1973 double yy = m_dheight - yi;
1974 double xf = xx + (m_dwidth<<2);
1977 matrix.translate(-xx, -yy);
1978 matrix.scale(m_txXScale, 1.);
1979 matrix.rotate(-angle *
PI / 180.);
1980 matrix.translate(xx, yy);
1981 matrix.transform(&xf, &yf);
1983 agg::path_storage path;
1984 path.start_new_path();
1986 path.move_to(xx, yy);
1987 path.line_to(xf, yf);
1989 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1991 agg::trans_single_path tcurve;
1992 tcurve.add_path(path);
1993 tcurve.preserve_x_scale(
true);
1999 fsegm.approximation_scale(3.0);
2000 fcurves.approximation_scale(2.0);
2008 const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
2011 m_fontManager->add_kerning(&xa, &ya);
2012 m_fontManager->init_embedded_adaptors(glyph, xa, ya);
2015 xa += glyph->advance_x;
2016 ya += glyph->advance_y;
2025 matrix.translate(-xx, -yy);
2026 matrix.rotate(-angle *
PI / 180.);
2027 matrix.translate(xx, yy);
2030 yf = yy + ya + m_fontEngine->height();
2031 yy -= m_fontEngine->height()/4.;
2040 matrix.transform(&a, &b);
2041 m_matrix.invert().transform(&a, &b);
2046 matrix.transform(&a, &b);
2047 m_matrix.invert().transform(&a, &b);
2052 matrix.transform(&a, &b);
2053 m_matrix.invert().transform(&a, &b);
2058 matrix.transform(&a, &b);
2059 m_matrix.invert().transform(&a, &b);
2067 double x = wp.
getX();
2068 double y = wp.
getY();
2070 m_matrix.transform(&x, &y);
2071 return getTextBoundary((
int)x, (
int)y, tx, angle, hAlign, vAlign);
2080 return getTextBoundary((
int)x, (
int)y, tx, angle, hAlign, vAlign);
2090 double v = (double)opacity/255.;
2091 m_txColor.opacity(v);
2096 if(m_fontEngine->create_font(family.c_str(), agg::glyph_ren_outline) ==
false)
2097 m_fontEngine->create_font(
"Verdana", agg::glyph_ren_outline);
2102 double size = 1.8 * psize;
2103 m_fontEngine->height(size);
2104 std::string f = m_fontEngine->font_signature();
2105 size_t i = f.find(
",");
2106 if(i != std::string::npos)
2114 m_fontEngine->italic(
false);
2116 m_fontEngine->italic(
true);
2118 std::string f = m_fontEngine->font_signature();
2119 size_t i = f.find(
",");
2120 if(i != std::string::npos)
2127 m_fontEngine->weight(weight);
2128 std::string f = m_fontEngine->font_signature();
2129 size_t i = f.find(
",");
2130 if(i != std::string::npos)
2137 m_txXScale = (double)stretch/100.;
2143 m_txDecorationType = 1;
2144 else if(m_txDecorationType == 1)
2145 m_txDecorationType = 0;
2151 m_txDecorationType = 2;
2152 else if(m_txDecorationType == 2)
2153 m_txDecorationType = 0;
2159 m_txDecorationType = 3;
2160 else if(m_txDecorationType == 3)
2161 m_txDecorationType = 0;
2171 m_txDecorationWidth = width;
2181 double v = (double)opacity/255.;
2182 m_txBoundaryColor.opacity(v);
2187 m_txBoundaryWidth = (double)width;
2192 m_textLineJustification = (int)just;
2197 m_textLineSpacing = spacing;
2203 delete []m_ptPatternBuffer;
2204 m_ptPatternBuffer = 0;
2214 m_ptMarkerType = (agg::marker_e)type;
2220 delete [] m_ptPatternBuffer;
2221 unsigned int tam = ncols * nrows *
DEPTH/8;
2222 m_ptPatternBuffer =
new agg::int8u[tam];
2223 for(i = 0; i < nrows; ++i)
2226 for(j = 0; j < ncols; ++j)
2230 m_ptPatternBuffer[n] = (agg::int8u)c.
getRed();
2231 m_ptPatternBuffer[n + 1] = (agg::int8u)c.
getGreen();
2232 m_ptPatternBuffer[n + 2] = (agg::int8u)c.
getBlue();
2233 m_ptPatternBuffer[n + 3] = (agg::int8u)c.
getAlpha();
2236 m_ptPatternRenderingBuffer.attach(m_ptPatternBuffer, ncols, nrows, -ncols *
DEPTH/8);
2259 int i, j, wdata, hdata;
2260 unsigned char* data = (
unsigned char*)getData(fileName, wdata, hdata);
2264 delete [] m_ptPatternBuffer;
2265 unsigned int tam = wdata * hdata *
DEPTH/8;
2266 m_ptPatternBuffer =
new agg::int8u[tam];
2267 memset(m_ptPatternBuffer, 0, tam);
2269 for(i = 0; i < hdata; ++i)
2271 int c = i * 3 * wdata;
2272 int d = i * 4 * wdata;
2273 for(j = 0; j < wdata; ++j)
2277 if(data[a] != 0 && data[a+1] != 0 && data[a+2] != 0)
2279 m_ptPatternBuffer[b] = data[a];
2280 m_ptPatternBuffer[b+1] = data[a+1];
2281 m_ptPatternBuffer[b+2] = data[a+2];
2282 m_ptPatternBuffer[b+3] = 255;
2287 m_ptPatternRenderingBuffer.attach(m_ptPatternBuffer, wdata, hdata, -wdata *
DEPTH/8);
2293 delete []m_linePatternBuffer;
2294 m_linePatternBuffer = 0;
2300 delete [] m_linePatternBuffer;
2301 unsigned int tam = ncols * nrows *
DEPTH/8;
2302 m_linePatternBuffer =
new agg::int8u[tam];
2303 for(i = 0; i < nrows; ++i)
2306 for(j = 0; j < ncols; ++j)
2310 m_linePatternBuffer[n] = (agg::int8u)c.
getRed();
2311 m_linePatternBuffer[n + 1] = (agg::int8u)c.
getGreen();
2312 m_linePatternBuffer[n + 2] = (agg::int8u)c.
getBlue();
2313 m_linePatternBuffer[n + 3] = 255;
2316 m_linePatternRenderingBuffer.attach(m_linePatternBuffer, ncols, nrows, -ncols *
DEPTH/8);
2340 int i, j, wdata, hdata;
2341 unsigned char* data = (
unsigned char*)getData(fileName, wdata, hdata);
2345 delete []m_linePatternBuffer;
2346 m_linePatternBuffer =
new agg::int8u[wdata * hdata *
DEPTH/8];
2348 for(i = 0; i < hdata; ++i)
2350 int c = i * 3 * wdata;
2351 int d = i * 4 * wdata;
2352 for(j = 0; j < wdata; ++j)
2356 m_linePatternBuffer[b] = data[a];
2357 m_linePatternBuffer[b+1] = data[a+1];
2358 m_linePatternBuffer[b+2] = data[a+2];
2359 m_linePatternBuffer[b+3] = 255;
2363 m_linePatternRenderingBuffer.attach(m_linePatternBuffer, wdata, hdata, -wdata *
DEPTH/8);
2374 delete []m_polyPatternBuffer;
2375 m_polyPatternBuffer = 0;
2381 delete []m_contourPatternBuffer;
2382 m_contourPatternBuffer = 0;
2388 delete [] m_polyPatternBuffer;
2389 unsigned int tam = ncols * nrows *
DEPTH/8;
2390 m_polyPatternBuffer =
new agg::int8u[tam];
2391 for(i = 0; i < nrows; ++i)
2394 for(j = 0; j < ncols; ++j)
2398 m_polyPatternBuffer[n] = (agg::int8u)c.
getRed();
2399 m_polyPatternBuffer[n + 1] = (agg::int8u)c.
getGreen();
2400 m_polyPatternBuffer[n + 2] = (agg::int8u)c.
getBlue();
2401 m_polyPatternBuffer[n + 3] = m_polyPatternOpacity;
2404 m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, ncols, nrows, -ncols *
DEPTH/8);
2426 int a, b, c, d, i, j, wdata, hdata;
2427 unsigned char* data = (
unsigned char*)getData(fileName, wdata, hdata);
2431 delete [] m_polyPatternBuffer;
2432 m_polyPatternBuffer =
new agg::int8u[wdata * hdata *
DEPTH/8];
2433 memset(m_polyPatternBuffer, 0, wdata * hdata *
DEPTH/8);
2434 for(i = 0; i < hdata; ++i)
2438 for(j = 0; j < wdata; ++j)
2442 m_polyPatternBuffer[b] = data[a];
2443 m_polyPatternBuffer[b+1] = data[a+1];
2444 m_polyPatternBuffer[b+2] = data[a+2];
2445 m_polyPatternBuffer[b+3] = m_polyPatternOpacity;
2449 m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, wdata, hdata, -wdata *
DEPTH/8);
2485 m_polyPatternWidth = w;
2490 m_polyPatternOpacity = opac;
2496 delete [] m_contourPatternBuffer;
2497 unsigned int tam = ncols * nrows *
DEPTH/8;
2498 m_contourPatternBuffer =
new agg::int8u[tam];
2499 for(i = 0; i < nrows; ++i)
2502 for(j = 0; j < ncols; ++j)
2506 m_contourPatternBuffer[n] = (agg::int8u)c.
getRed();
2507 m_contourPatternBuffer[n + 1] = (agg::int8u)c.
getGreen();
2508 m_contourPatternBuffer[n + 2] = (agg::int8u)c.
getBlue();
2509 m_contourPatternBuffer[n + 3] = 255;
2512 m_contourPatternRenderingBuffer.attach(m_contourPatternBuffer, ncols, nrows, -ncols *
DEPTH/8);
2536 int i, j, wdata, hdata;
2537 unsigned char* data = (
unsigned char*)getData(fileName, wdata, hdata);
2541 delete []m_contourPatternBuffer;
2542 m_contourPatternBuffer =
new agg::int8u[wdata * hdata *
DEPTH/8];
2544 for(i = 0; i < hdata; ++i)
2546 int c = i * 3 * wdata;
2547 int d = i * 4 * wdata;
2548 for(j = 0; j < wdata; ++j)
2552 m_contourPatternBuffer[b] = data[a];
2553 m_contourPatternBuffer[b+1] = data[a+1];
2554 m_contourPatternBuffer[b+2] = data[a+2];
2555 m_contourPatternBuffer[b+3] = 255;
2559 m_contourPatternRenderingBuffer.attach(m_contourPatternBuffer, wdata, hdata, -wdata *
DEPTH/8);
2564 m_polyContourWidth = w;
2760 if(x == 0 && y == 0 && w == 0 && h == 0)
2763 for(i = 0; i < m_dheight; ++i)
2766 for(i = 0; i < m_dheight; ++i)
2768 k = (i<<2) * m_dwidth;
2769 for(j = 0; j < m_dwidth; ++j)
2780 for(i = 0; i < h; ++i)
2783 for(i = 0; i < h; ++i)
2785 k = ((y+i)<<2) * m_dwidth;
2786 for(j = 0; j < w; ++j)
2801 FILE* fp = fopen(file_name.c_str(),
"wb");
2804 fprintf(fp,
"P6 %d %d 255 ", m_dwidth, m_dheight);
2805 fwrite(m_buffer, 1, m_dwidth * m_dheight * 3, fp);
2813 char* buf =
new char[m_dwidth * m_dheight * 3];
2815 for(i = 0; i < m_dheight; ++i)
2817 int c = i * 3 * m_dwidth;
2818 int d = i * 4 * m_dwidth;
2819 for(j = 0; j < m_dwidth; ++j)
2823 buf[a] = m_buffer[b+0];
2824 buf[a+1] = m_buffer[b+1];
2825 buf[a+2] = m_buffer[b+2];
2829 FILE* fp = fopen(file_name.c_str(),
"wb");
2832 fprintf(fp,
"P6 %d %d 255 ", m_dwidth, m_dheight);
2833 fwrite(buf, 1, m_dwidth * m_dheight * 3, fp);
2845 std::string fe = te::common::GetFileExtension(fileName);
2855 FILE* fp = fopen(fileName.c_str(),
"rb");
2859 fread(buf, 1, 256, fp);
2867 ss = s.substr(pp, p-pp);
2868 sscanf(ss.c_str(),
"%d", &w);
2871 ss = s.substr(pp, p-pp);
2872 sscanf(ss.c_str(),
"%d", &h);
2882 ss = s.substr(pp, p-pp);
2883 sscanf(ss.c_str(),
"%d %d", &w, &h);
2890 char* data =
new char[size];
2891 fread(data, 1, size, fp);
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void setFontFamily(const std::string &family)
It sets the text font family.
char * drawPointZ(char *point)
It draws the point in WKB format on canvas.
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
A canvas built on top of Anti Grain Geometry.
void save(const char *fileName, te::map::Canvas::ImageType t, int quality=75, int fg=0) const
It saves the canvas content to a file image in the specified format type.
MultiPolygon is a MultiSurface whose elements are Polygons.
void setBackgroundColor(const te::color::RGBAColor &color)
It sets the canvas background color.
TextDecoration getDecoration() const
It returns the font decoration.
void setPolygonFillStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the polygon fill style.
font_engine_type * m_fontEngine
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
const double & getLetterSpacing() const
It returns the letter spacing.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
FontWeight
Font weight for drawing text.
char * getImage(te::map::Canvas::ImageType t, size_t &size) const
It returns the internal contents as an image.
const double & getTextOpacity() const
It returns the text opacity.
void setLineStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the line style.
void transform(int srid)
It converts the coordinate values of the geometry to the new spatial reference system.
void adjustWorldWindow(double &llx, double &lly, double &urx, double &ury, const HAlignType &ha=HCenter, const VAlignType &va=VCenter)
It adjusts the world (or window) coordinates area (supposing a cartesian reference system)...
int m_dwidth
The device width.
int getRed() const
It returns the red component color value (a value from 0 to 255).
te::color::RGBAColor getBackgroundColor() const
It returns the canvas background color.
#define TE_EWKB_SRID_FLAG
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
void setPolygonContourStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the pen style used to draw the boundary of polygon geometries.
color_type m_ptColor
Point color.
void setTextStyle(te::at::FontStyle style)
It sets the text style.
void drawPixel(int x, int y)
It sets a pixel using the point pen.
const std::string & getFamily() const
It returns the font family.
LineJustification
Line justification for drawing multi line text.
color_type m_polyFillColor
Polygon fill color.
FontStyle
Font style for drawing text.
unsigned char * getBuffer() const
It gets a RGBA colors from buffer.
agg::rendering_buffer * m_rb
int m_dheight
The device height.
color_type m_bgColor
Canvas background color. Defaults: white fully transparent.
void clear()
It clears the canvas content and fills with the background color.
const double & getPointSize() const
It returns the font point size.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
char * drawGeometry(char *geom)
It draws the geometry in WKB format on canvas.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
agg::int8u * m_contourPatternBuffer
color_type m_polyContourColor
Polygon contoyr color.
void drawImage(char *src, int size, te::map::Canvas::ImageType t)
It draws the src pixmap over the canvas.
agg::conv_transform< conv_font_segm_type, agg::trans_single_path > conv_font_trans_type
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
agg::conv_segmentator< conv_font_curve_type > conv_font_segm_type
A Text may contain 1 or more Text Elements.
static agg::int8u brightness_to_alpha[256 *3]
font_manager_type * m_fontManager
unsigned int m_polyPatternWidth
The pattern width used to fill a polygon.
An utility struct for representing 2D coordinates.
void setPointStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the point style.
HorizontalAlignment getHorizontalAlignment() const
It returns the horizontal text alignment.
char * drawMultiPolygon(char *mpoly)
It draws the MultiPolygon in WKB format on canvas.
agg::int8u * m_ptPatternBuffer
A point with a z-coordinate value and an associated measurement.
virtual Geometry * getBoundary() const
It returns the geometry boundary.
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
void setPolygonPatternWidth(const int &w)
It sets the polycon brush icon width.
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
const Attributes * getAttributes() const
it returns the text attributes.
const te::gm::Geometry * getLeaderLine() const
it returns the text leader line.
A point with an associated measure.
color_type m_txBoundaryColor
Text boundary color.
FontStyle getStyle() const
It returns the font style.
TextDecoration
Text decoration for drawing text.
void draw(te::gm::Geometry *geom)
It draws the geometry on canvas.
void setTextWeight(te::at::FontWeight weight)
It sets the text weight.
A LinearRing is a LineString that is both closed and simple.
char * drawMultiPoint(char *mpoint)
It draws the multipoint in WKB format on canvas.
void setLineWidth(const int &w)
It sets the line width.
MultiPoint is a GeometryCollection whose elements are restricted to points.
void setTextMultiLineSpacing(const int &spacing)
It sets the multi line text spacing.
void setTextColor(const te::color::RGBAColor &color)
It sets the text drawing color.
char * getData(const std::string &file_name, int &w, int &h)
A point with z-coordinate value.
LineString is a curve with linear interpolation between points.
char * drawPolygon(char *poly)
It draws the polygon in WKB format on canvas.
HorizontalAlignment
Horizontal alignment for drawing text.
bool write_ppm(const std::string &file_name)
It draws a text.
void setTextUnderline(bool b)
It sets the text underline flag.
te::gm::Polygon * getTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It returns text boundary.
const double & getY() const
It returns the Point y-coordinate value.
void setTextBoundaryWidth(const int &width)
It sets the text boundary width.
A point with x and y coordinate values.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
VerticalAlignment getVerticalAlignment() const
It returns the vertical text alignment.
An Envelope defines a 2D rectangular region.
virtual te::dt::AbstractData * clone() const
It clones the point.
void setTextOpacity(const int &opacity)
It sets the text opacity.
agg::marker_e m_ptMarkerType
const std::vector< Element * > & getElements() const
It returns the elements.
const double & getLineSpacing() const
It returns the multi line spacing.
void drawText(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws a text.
char * drawLineString(char *line)
It draws the line string in WKB format on canvas.
agg::pixfmt_rgba32_pre pixfmt_pre
agg::int8u * m_polyPatternBuffer
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
void setTextDecorationColor(const te::color::RGBAColor &color)
It sets the text strike out flag.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
void drawTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws the text boundary.
const std::string & getValue() const
it returns the text string.
char * drawPointM(char *point)
It draws the point in WKB format on canvas.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
void setTextOverline(bool b)
It sets the text overline flag.
agg::int8u * m_linePatternBuffer
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setTextMultiLineJustification(const te::at::LineJustification &just)
It sets the multi line text justification.
FontWeight getWeight() const
It returns the font weight.
double m_lly
Lower left corner y-coordinate.
agg::pixfmt_rgba32 pixfmt
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
void setTextPointSize(double psize)
It sets the text Point Size.
MultiLineString is a MultiCurve whose elements are LineStrings.
pattern_src_brightness_to_alpha_rgba8(agg::rendering_buffer &rb)
void setTextDecorationWidth(int width)
It sets the text strike out flag.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
te::color::RGBAColor ** getColorsFromBuffer(int x=0, int y=0, int w=0, int h=0) const
It gets a RGBA colors from buffer.
void setTextStrikeOut(bool b)
It sets the text strike out flag.
VerticalAlignment
Vertical alignment for drawing text.
double m_ury
Upper right corner y-coordinate.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
void Convert2OGCWKBType(unsigned int &gType)
It converts the PostGIS geometry type to a pure OGC WKB code.
char * drawPointZM(char *point)
It draws the point in WKB format on canvas.
const te::gm::Geometry * getLocation() const
it returns the text location.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
color_type m_txColor
Text color.
void setTextBoundaryColor(const te::color::RGBAColor &color)
It sets the text boundary drawing color.
LineJustification getLineJustification() const
It returns the multi line justification.
double m_txBoundaryWidth
Text boundary color.
double m_lineWidth
Line width.
char * drawPoint(char *point)
It draws the point in WKB format on canvas.
agg::rendering_buffer m_renderingBuffer
void setPointMarkerType(const ptMarkerType &type)
It sets the point marker type.
agg::rgba8 pixel(int x, int y) const
double m_polyContourWidth
Polygon contour width.
void setPolygonContourWidth(const int &w)
It sets the polycon contour width.
void setY(const double &y)
It sets the Point y-coordinate value.
color_type m_lineColor
Line color.
int m_ptWidth
Point width.
It is a collection of other geometric objects.
agg::conv_curve< font_manager_type::path_adaptor_type > conv_font_curve_type
char * drawGeometryCollection(char *g)
It draws the GeometryCollection in WKB format on canvas.
char * drawMultiLineString(char *mline)
It draws the MultiLineString in WKB format on canvas.
color_type m_txDecorationColor
void freeImage(char *img) const
This is the method that you should use to release a image generated by the canvas.
const double & getX() const
It returns the Point x-coordinate value.
void resize(int w, int h)
It adjusts the canvas size (width and height).
void setTextBoundaryOpacity(const int &opacity)
It sets the text boundary opacity.
void setPolygonPatternOpacity(const unsigned char &opac)
It sets the polycon brush icon width.
double m_txDecorationWidth
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
void setTextStretch(size_t stretch)
It sets the text stretch.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
agg::renderer_base< pixfmt > m_rendererBase
void setPointWidth(int w)
It sets the point drawing color.