virtual void operator()(vector_marker_render_thunk const& thunk) { using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>; // comp blender using buf_type = agg::rendering_buffer; using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>; using renderer_base = agg::renderer_base<pixfmt_comp_type>; using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>; using svg_attribute_type = agg::pod_bvector<svg::path_attributes>; using svg_renderer_type = svg::svg_renderer_agg<svg_path_adapter, svg_attribute_type, renderer_type, pixfmt_comp_type>; ras_ptr_->reset(); buf_type render_buffer(buf_->bytes(), buf_->width(), buf_->height(), buf_->row_size()); pixfmt_comp_type pixf(render_buffer); pixf.comp_op(static_cast<agg::comp_op_e>(thunk.comp_op_)); renderer_base renb(pixf); svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(thunk.src_->source()); svg_path_adapter svg_path(stl_storage); svg_renderer_type svg_renderer(svg_path, thunk.attrs_); agg::trans_affine offset_tr = thunk.tr_; offset_tr.translate(offset_.x, offset_.y); render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(), offset_tr, thunk.opacity_, thunk.snap_to_pixels_); }
void render_pattern<image_rgba8>(rasterizer & ras, marker_svg const& marker, agg::trans_affine const& tr, double opacity, image_rgba8 & image) { using pixfmt = agg::pixfmt_rgba32_pre; using renderer_base = agg::renderer_base<pixfmt>; using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>; agg::scanline_u8 sl; mapnik::box2d<double> const& bbox = marker.bounding_box() * tr; mapnik::coord<double,2> c = bbox.center(); agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height()); mtx = tr * mtx; agg::rendering_buffer buf(image.bytes(), image.width(), image.height(), image.row_size()); pixfmt pixf(buf); renderer_base renb(pixf); mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(marker.get_data()->source()); mapnik::svg::svg_path_adapter svg_path(stl_storage); mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter, agg::pod_bvector<mapnik::svg::path_attributes>, renderer_solid, pixfmt > svg_renderer(svg_path, marker.get_data()->attributes()); svg_renderer.render(ras, sl, renb, mtx, opacity, bbox); }
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr, double opacity) { using pixfmt = agg::pixfmt_rgba32_pre; using renderer_base = agg::renderer_base<pixfmt>; using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>; agg::scanline_u8 sl; mapnik::box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box() * tr; mapnik::coord<double,2> c = bbox.center(); agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height()); mtx = tr * mtx; std::shared_ptr<mapnik::image_data_32> image = std::make_shared<mapnik::image_data_32>(bbox.width(), bbox.height()); agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4); pixfmt pixf(buf); renderer_base renb(pixf); mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage((*marker.get_vector_data())->source()); mapnik::svg::svg_path_adapter svg_path(stl_storage); mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter, agg::pod_bvector<mapnik::svg::path_attributes>, renderer_solid, agg::pixfmt_rgba32_pre > svg_renderer(svg_path, (*marker.get_vector_data())->attributes()); svg_renderer.render(ras, sl, renb, mtx, opacity, bbox); return image; }
void grid_renderer<T>::render_marker(Feature const& feature, unsigned int step, const int x, const int y, marker &marker, const agg::trans_affine & tr, double opacity) { if (marker.is_vector()) { typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_scanline_bin_solid<ren_base> renderer; agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_); mapnik::pixfmt_gray16 pixf(buf); ren_base renb(pixf); renderer ren(renb); ras_ptr->reset(); box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box(); coord<double,2> c = bbox.center(); // center the svg marker on '0,0' agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); // apply symbol transformation to get to map space mtx *= tr; mtx *= agg::trans_affine_scaling(scale_factor_*(1.0/step)); // render the marker at the center of the marker box mtx.translate(x+0.5 * marker.width(), y+0.5 * marker.height()); vertex_stl_adapter<svg_path_storage> stl_storage((*marker.get_vector_data())->source()); svg_path_adapter svg_path(stl_storage); svg_renderer<svg_path_adapter, agg::pod_bvector<path_attributes>, renderer, mapnik::pixfmt_gray16> svg_renderer(svg_path, (*marker.get_vector_data())->attributes()); svg_renderer.render_id(*ras_ptr, sl, renb, feature.id(), mtx, opacity, bbox); } else { image_data_32 const& data = **marker.get_bitmap_data(); if (step == 1 && scale_factor_ == 1.0) { pixmap_.set_rectangle(feature.id(), data, x, y); } else { double ratio = (1.0/step); image_data_32 target(ratio * data.width(), ratio * data.height()); mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR, scale_factor_, 0.0, 0.0, 1.0, ratio); pixmap_.set_rectangle(feature.id(), target, x, y); } } pixmap_.add_feature(feature); }
virtual void render_marker(svg_path_ptr const& src, svg_path_adapter & path, svg_attribute_type const& attrs, markers_dispatch_params const& params, agg::trans_affine const& marker_tr) { SvgRenderer svg_renderer(path, attrs); render_vector_marker(svg_renderer, ras_, renb_, src->bounding_box(), marker_tr, params.opacity, params.snap_to_pixels); }
virtual void operator()(vector_marker_render_thunk const& thunk) { using buf_type = grid_rendering_buffer; using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>; using svg_renderer_type = svg::renderer_agg<svg_path_adapter, svg_attribute_type, renderer_type, pixfmt_type>; buf_type render_buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_); ras_.reset(); pixfmt_type pixf(render_buf); grid_renderer_base_type renb(pixf); renderer_type ren(renb); svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(thunk.src_->source()); svg_path_adapter svg_path(stl_storage); svg_renderer_type svg_renderer(svg_path, thunk.attrs_); agg::trans_affine offset_tr = thunk.tr_; offset_tr.translate(offset_.x, offset_.y); agg::scanline_bin sl; svg_renderer.render_id(ras_, sl, renb, feature_.id(), offset_tr, thunk.opacity_, thunk.src_->bounding_box()); pixmap_.add_feature(feature_); }