diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp index 8b72ea81d..d72f1afd9 100644 --- a/benchmark/test_polygon_clipping.cpp +++ b/benchmark/test_polygon_clipping.cpp @@ -41,7 +41,7 @@ void render(mapnik::geometry_type & geom, mapnik::box2d padded_extent = extent; padded_extent.pad(10); mapnik::view_transform tr(im.width(),im.height(),padded_extent,0,0); - agg::rendering_buffer buf(im.getBytes(),im.width(),im.height(), im.width() * 4); + agg::rendering_buffer buf(im.getBytes(),im.width(),im.height(), im.getRowSize()); agg::pixfmt_rgba32_plain pixf(buf); ren_base renb(pixf); renderer ren(renb); diff --git a/include/mapnik/agg_render_marker.hpp b/include/mapnik/agg_render_marker.hpp index 5f77303ed..188b7de1e 100644 --- a/include/mapnik/agg_render_marker.hpp +++ b/include/mapnik/agg_render_marker.hpp @@ -81,7 +81,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon) && (std::fabs(1.0 - tr.sy) < agg::affine_epsilon)) { - agg::rendering_buffer src_buffer((unsigned char *)src.getBytes(),src.width(),src.height(),src.width() * 4); + agg::rendering_buffer src_buffer((unsigned char *)src.getBytes(),src.width(),src.height(),src.getRowSize()); pixfmt_pre pixf_mask(src_buffer); if (snap_to_pixels) { @@ -125,7 +125,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(), src.width(), src.height(), - src.width()*4); + src.getRowSize()); pixfmt_pre pixf(marker_buf); img_accessor_type ia(pixf); agg::trans_affine final_tr(p, 0, 0, width, height); diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index 3c2a54d6d..215703efb 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -401,7 +401,7 @@ void apply_filter(Src & src, Filter const& filter) template void apply_filter(Src & src, agg_stack_blur const& op) { - agg::rendering_buffer buf(src.getBytes(),src.width(),src.height(), src.width() * 4); + agg::rendering_buffer buf(src.getBytes(),src.width(),src.height(), src.getRowSize()); agg::pixfmt_rgba32_pre pixf(buf); agg::stack_blur_rgba32(pixf,op.rx,op.ry); } diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 83aaed6bd..ea2f7e21b 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -331,7 +331,7 @@ void agg_renderer::render_marker(pixel_position const& pos, agg::rendering_buffer buf(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), - current_buffer_->width() * 4); + current_buffer_->getRowSize()); pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast(comp_op)); renderer_base renb(pixf); @@ -416,7 +416,7 @@ void agg_renderer::render_marker(pixel_position const& pos, agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(), src.width(), src.height(), - src.width()*4); + src.getRowSize()); agg::pixfmt_rgba32_pre marker_pixf(marker_buf); using img_accessor_type = agg::image_accessor_clone; using interpolator_type = agg::span_interpolator_linear; @@ -456,7 +456,7 @@ void agg_renderer::debug_draw_box(box2d const& box, agg::rendering_buffer buf(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), - current_buffer_->width() * 4); + current_buffer_->getRowSize()); debug_draw_box(buf, box, x, y, angle); } diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index 5d6fba5c9..1b3eeee42 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -58,7 +58,7 @@ void agg_renderer::process(building_symbolizer const& sym, using ren_base = agg::renderer_base; using renderer = agg::renderer_scanline_aa_solid; - agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); + agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); agg::pixfmt_rgba32_pre pixf(buf); ren_base renb(pixf); diff --git a/src/agg/process_dot_symbolizer.cpp b/src/agg/process_dot_symbolizer.cpp index 7838a920b..226dae768 100644 --- a/src/agg/process_dot_symbolizer.cpp +++ b/src/agg/process_dot_symbolizer.cpp @@ -70,7 +70,7 @@ void agg_renderer::process(dot_symbolizer const& sym, double opacity = get(sym, keys::opacity, feature, common_.vars_, 1.0); color const& fill = get(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128)); ras_ptr->reset(); - agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(),current_buffer_->width() * 4); + agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(),current_buffer_->getRowSize()); using blender_type = agg::comp_op_adaptor_rgba_pre; using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba; using renderer_base = agg::renderer_base; diff --git a/src/agg/process_group_symbolizer.cpp b/src/agg/process_group_symbolizer.cpp index f1ae6a30b..d84ae23f8 100644 --- a/src/agg/process_group_symbolizer.cpp +++ b/src/agg/process_group_symbolizer.cpp @@ -81,7 +81,7 @@ struct thunk_renderer renderer_type, pixfmt_comp_type>; ras_ptr_->reset(); - buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->width() * 4); + buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->getRowSize()); pixfmt_comp_type pixf(render_buffer); pixf.comp_op(static_cast(thunk.comp_op_)); renderer_base renb(pixf); @@ -102,7 +102,7 @@ struct thunk_renderer using renderer_base = agg::renderer_base; ras_ptr_->reset(); - buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->width() * 4); + buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->getRowSize()); pixfmt_comp_type pixf(render_buffer); pixf.comp_op(static_cast(thunk.comp_op_)); renderer_base renb(pixf); diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 5e5821ab0..d1e4d5a15 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -103,7 +103,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, value_double simplify_tolerance = get(sym, feature, common_.vars_); value_double smooth = get(sym, feature, common_.vars_); - agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); + agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); pixfmt_type pixf(buf); pixf.comp_op(static_cast(get(sym, feature, common_.vars_))); renderer_base ren_base(pixf); diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 126c7475c..5392ca8f5 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -109,7 +109,7 @@ void agg_renderer::process(line_symbolizer const& sym, gamma_ = gamma; } - agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); + agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); using color_type = agg::rgba8; using order_type = agg::order_rgba; diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index b05787691..49b6bef89 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -192,7 +192,7 @@ void agg_renderer::process(markers_symbolizer const& sym, gamma_ = gamma; } - buf_type render_buffer(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), current_buffer_->width() * 4); + buf_type render_buffer(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), current_buffer_->getRowSize()); box2d clip_box = clipping_extent(common_); auto renderer_context = std::tie(render_buffer,*ras_ptr,pixmap_); diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 38a0eee8c..17f897147 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -92,7 +92,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, using path_type = transform_path_adapter; agg::rendering_buffer buf(current_buffer_->getBytes(), current_buffer_->width(), - current_buffer_->height(), current_buffer_->width() * 4); + current_buffer_->height(), current_buffer_->getRowSize()); ras_ptr->reset(); value_double gamma = get(sym, feature, common_.vars_); gamma_method_enum gamma_method = get(sym, feature, common_.vars_); diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 13b9f1e9f..af53dff06 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -61,7 +61,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, } box2d clip_box = clipping_extent(common_); - agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); + agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); render_polygon_symbolizer( sym, feature, prj_trans, common_, clip_box, *ras_ptr, diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp index 6667bce1c..878b0a611 100644 --- a/src/image_compositing.cpp +++ b/src/image_compositing.cpp @@ -139,7 +139,7 @@ struct rendering_buffer uint8_t const* buf() const { return data_.getBytes(); } unsigned width() const { return data_.width();} unsigned height() const { return data_.height();} - int stride() const { return data_.width() * sizeof(pixel_type);} + int stride() const { return data_.getRowSize();} uint8_t const* row_ptr(int, int y, unsigned) {return row_ptr(y);} uint8_t const* row_ptr(int y) const { return reinterpret_cast(data_.getRow(y)); } row_data row (int y) const { return row_data(0, data_.width() - 1, row_ptr(y)); } @@ -161,7 +161,7 @@ MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_ using pixfmt_type = agg::pixfmt_custom_blend_rgba; using renderer_type = agg::renderer_base; - agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.width() * 4); + agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.getRowSize()); const_rendering_buffer src_buffer(src); pixfmt_type pixf(dst_buffer); pixf.comp_op(static_cast(mode)); diff --git a/src/image_util.cpp b/src/image_util.cpp index 33d62022c..efce27448 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -480,7 +480,7 @@ bool premultiply_visitor::operator() (image_rgba8 & data) { if (!data.get_premultiplied()) { - agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.width() * 4); + agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.getRowSize()); agg::pixfmt_rgba32 pixf(buffer); pixf.premultiply(); data.set_premultiplied(true); @@ -504,7 +504,7 @@ bool demultiply_visitor::operator() (image_rgba8 & data) { if (data.get_premultiplied()) { - agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.width() * 4); + agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.getRowSize()); agg::pixfmt_rgba32_pre pixf(buffer); pixf.demultiply(); data.set_premultiplied(false); @@ -1253,6 +1253,15 @@ template MAPNIK_DECL uint8_t get_pixel(image_any const&, std::size_t, std::size_ template MAPNIK_DECL int8_t get_pixel(image_any const&, std::size_t, std::size_t); template MAPNIK_DECL float get_pixel(image_any const&, std::size_t, std::size_t); template MAPNIK_DECL double get_pixel(image_any const&, std::size_t, std::size_t); +template MAPNIK_DECL color get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL uint32_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL int32_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL uint16_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL int16_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL uint8_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL int8_t get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL float get_pixel(image_view_any const&, std::size_t, std::size_t); +template MAPNIK_DECL double get_pixel(image_view_any const&, std::size_t, std::size_t); // Temporary remove these later! @@ -1452,7 +1461,7 @@ struct visitor_compare template <> MAPNIK_DECL unsigned compare(image_any const& im1, image_any const& im2, double threshold, bool alpha) { - util::apply_visitor(detail::visitor_compare(im2, threshold, alpha), im1); + return util::apply_visitor(detail::visitor_compare(im2, threshold, alpha), im1); } } // end ns diff --git a/src/renderer_common/render_pattern.cpp b/src/renderer_common/render_pattern.cpp index 8fc1ac5c2..39213cc0f 100644 --- a/src/renderer_common/render_pattern.cpp +++ b/src/renderer_common/render_pattern.cpp @@ -55,7 +55,7 @@ std::shared_ptr render_pattern(rasterizer & ras, mtx = tr * mtx; std::shared_ptr image = std::make_shared(bbox.width(), bbox.height()); - agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4); + agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize()); pixfmt pixf(buf); renderer_base renb(pixf); @@ -98,7 +98,7 @@ std::shared_ptr render_pattern(rasterizer & ras, mtx = tr * mtx; std::shared_ptr image = std::make_shared(bbox.width(), bbox.height()); - agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width()); + agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize()); pixfmt pixf(buf); renderer_base renb(pixf); @@ -132,7 +132,7 @@ std::shared_ptr render_pattern(rasterizer & ras, mtx = tr * mtx; std::shared_ptr image = std::make_shared(bbox.width(), bbox.height()); - agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 2); + agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize()); pixfmt pixf(buf); renderer_base renb(pixf); @@ -166,7 +166,7 @@ std::shared_ptr render_pattern(rasterizer & ras, mtx = tr * mtx; std::shared_ptr image = std::make_shared(bbox.width(), bbox.height()); - agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4); + agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize()); pixfmt pixf(buf); renderer_base renb(pixf); diff --git a/utils/svg2png/svg2png.cpp b/utils/svg2png/svg2png.cpp index 24f11e623..f770cbc83 100644 --- a/utils/svg2png/svg2png.cpp +++ b/utils/svg2png/svg2png.cpp @@ -158,7 +158,7 @@ int main (int argc,char** argv) } // 10 pixel buffer to avoid edge clipping of 100% svg's mapnik::image_rgba8 im(w+0,h+0); - agg::rendering_buffer buf(im.getBytes(), im.width(), im.height(), im.width() * 4); + agg::rendering_buffer buf(im.getBytes(), im.width(), im.height(), im.getRowSize()); pixfmt pixf(buf); renderer_base renb(pixf);