A large set of updates:
* Added new gray data types adding those to the variants and updating all the code necessary for them * Added basic SSE to the image compare method, (only for RGBA) must be enabled with the -DSSE_MATH flag this is not yet put into the build process in any location. * Fixed the resulting image for some TIFF visual tests, most likely they were incorrect due to fixes in TIFF reader * Added some MAPNIK_DECL where necessary to grid rendering. * Added support for more data types in GDAL plugin with grayscale images. * Added views for all the new gray data types * Updated python bindings for new gray data types. Ref #2681
|
@ -157,25 +157,22 @@ struct get_pixel_visitor
|
|||
throw std::runtime_error("Can not return a null image from a pixel (shouldn't have reached here)");
|
||||
}
|
||||
|
||||
PyObject* operator() (mapnik::image_rgba8 const& im)
|
||||
template <typename T>
|
||||
PyObject* operator() (T const& im)
|
||||
{
|
||||
return PyInt_FromLong(mapnik::get_pixel<uint32_t>(im, x_, y_));
|
||||
}
|
||||
|
||||
PyObject* operator() (mapnik::image_gray8 const& im)
|
||||
{
|
||||
return PyInt_FromLong(mapnik::get_pixel<uint8_t>(im, x_, y_));
|
||||
}
|
||||
|
||||
PyObject* operator() (mapnik::image_gray16 const& im)
|
||||
{
|
||||
return PyInt_FromLong(mapnik::get_pixel<uint16_t>(im, x_, y_));
|
||||
using pixel_type = typename T::pixel_type;
|
||||
return PyInt_FromLong(mapnik::get_pixel<pixel_type>(im, x_, y_));
|
||||
}
|
||||
|
||||
PyObject* operator() (mapnik::image_gray32f const& im)
|
||||
{
|
||||
return PyFloat_FromDouble(mapnik::get_pixel<double>(im, x_, y_));
|
||||
}
|
||||
|
||||
PyObject* operator() (mapnik::image_gray64f const& im)
|
||||
{
|
||||
return PyFloat_FromDouble(mapnik::get_pixel<double>(im, x_, y_));
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned x_;
|
||||
|
@ -388,8 +385,15 @@ void export_image()
|
|||
enum_<mapnik::image_dtype>("ImageType")
|
||||
.value("rgba8", mapnik::image_dtype_rgba8)
|
||||
.value("gray8", mapnik::image_dtype_gray8)
|
||||
.value("gray8s", mapnik::image_dtype_gray8s)
|
||||
.value("gray16", mapnik::image_dtype_gray16)
|
||||
.value("gray16s", mapnik::image_dtype_gray16s)
|
||||
.value("gray32", mapnik::image_dtype_gray32)
|
||||
.value("gray32s", mapnik::image_dtype_gray32s)
|
||||
.value("gray32f", mapnik::image_dtype_gray32f)
|
||||
.value("gray64", mapnik::image_dtype_gray64)
|
||||
.value("gray64s", mapnik::image_dtype_gray64s)
|
||||
.value("gray64f", mapnik::image_dtype_gray64f)
|
||||
;
|
||||
|
||||
class_<image_any,std::shared_ptr<image_any>, boost::noncopyable >("Image","This class represents a image.",init<int,int>())
|
||||
|
|
|
@ -49,8 +49,8 @@ template <typename T>
|
|||
class MAPNIK_DECL hit_grid
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using data_type = mapnik::image<value_type>;
|
||||
using value_type = typename T::type;
|
||||
using data_type = mapnik::image<T>;
|
||||
using lookup_type = std::string;
|
||||
// mapping between pixel id and key
|
||||
using feature_key_type = std::map<value_type, lookup_type>;
|
||||
|
@ -147,12 +147,12 @@ public:
|
|||
return data_;
|
||||
}
|
||||
|
||||
inline T const * raw_data() const
|
||||
inline value_type const * raw_data() const
|
||||
{
|
||||
return data_.getData();
|
||||
}
|
||||
|
||||
inline T* raw_data()
|
||||
inline value_type* raw_data()
|
||||
{
|
||||
return data_.getData();
|
||||
}
|
||||
|
@ -222,10 +222,9 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
using grid = hit_grid<mapnik::value_integer>;
|
||||
using grid = hit_grid<mapnik::value_integer_pixel>;
|
||||
|
||||
}
|
||||
#endif //MAPNIK_GRID_HPP
|
||||
|
|
|
@ -196,7 +196,7 @@ private:
|
|||
feature_type const& features_;
|
||||
};
|
||||
|
||||
using grid_view = hit_grid_view<mapnik::image<mapnik::value_integer> >;
|
||||
using grid_view = hit_grid_view<mapnik::image<mapnik::value_integer_pixel> >;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/pixel_types.hpp>
|
||||
|
||||
// stl
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
@ -120,7 +122,8 @@ template <typename T, std::size_t max_size = 65535>
|
|||
class image
|
||||
{
|
||||
public:
|
||||
using pixel_type = T;
|
||||
using pixel = T;
|
||||
using pixel_type = typename T::type;
|
||||
static constexpr std::size_t pixel_size = sizeof(pixel_type);
|
||||
private:
|
||||
detail::image_dimensions<max_size> dimensions_;
|
||||
|
@ -143,7 +146,7 @@ public:
|
|||
if (pData_ && initialize) std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), 0);
|
||||
}
|
||||
|
||||
image(image<pixel_type> const& rhs)
|
||||
image(image<T> const& rhs)
|
||||
: dimensions_(rhs.dimensions_),
|
||||
buffer_(rhs.buffer_),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
|
@ -153,7 +156,7 @@ public:
|
|||
painted_(rhs.painted_)
|
||||
{}
|
||||
|
||||
image(image<pixel_type> && rhs) noexcept
|
||||
image(image<T> && rhs) noexcept
|
||||
: dimensions_(std::move(rhs.dimensions_)),
|
||||
buffer_(std::move(rhs.buffer_)),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
|
@ -166,13 +169,13 @@ public:
|
|||
rhs.pData_ = nullptr;
|
||||
}
|
||||
|
||||
image<pixel_type>& operator=(image<pixel_type> rhs)
|
||||
image<T>& operator=(image<T> rhs)
|
||||
{
|
||||
swap(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(image<pixel_type> & rhs)
|
||||
void swap(image<T> & rhs)
|
||||
{
|
||||
std::swap(dimensions_, rhs.dimensions_);
|
||||
std::swap(buffer_, rhs.buffer_);
|
||||
|
@ -312,17 +315,31 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
using image_rgba8 = image<std::uint32_t>;
|
||||
using image_gray8 = image<std::uint8_t> ;
|
||||
using image_gray16 = image<std::int16_t>;
|
||||
using image_gray32f = image<float>;
|
||||
using image_rgba8 = image<rgba8_t>;
|
||||
using image_gray8 = image<gray8_t>;
|
||||
using image_gray8s = image<gray8s_t>;
|
||||
using image_gray16 = image<gray16_t>;
|
||||
using image_gray16s = image<gray16s_t>;
|
||||
using image_gray32 = image<gray32_t>;
|
||||
using image_gray32s = image<gray32s_t>;
|
||||
using image_gray32f = image<gray32f_t>;
|
||||
using image_gray64 = image<gray64_t>;
|
||||
using image_gray64s = image<gray64s_t>;
|
||||
using image_gray64f = image<gray64f_t>;
|
||||
|
||||
enum image_dtype : std::uint8_t
|
||||
{
|
||||
image_dtype_rgba8 = 0,
|
||||
image_dtype_gray8,
|
||||
image_dtype_gray8s,
|
||||
image_dtype_gray16,
|
||||
image_dtype_gray16s,
|
||||
image_dtype_gray32,
|
||||
image_dtype_gray32s,
|
||||
image_dtype_gray32f,
|
||||
image_dtype_gray64,
|
||||
image_dtype_gray64s,
|
||||
image_dtype_gray64f,
|
||||
image_dtype_null
|
||||
};
|
||||
|
||||
|
|
|
@ -58,8 +58,15 @@ struct image_null
|
|||
using image_base = util::variant<image_null,
|
||||
image_rgba8,
|
||||
image_gray8,
|
||||
image_gray8s,
|
||||
image_gray16,
|
||||
image_gray32f>;
|
||||
image_gray16s,
|
||||
image_gray32,
|
||||
image_gray32s,
|
||||
image_gray32f,
|
||||
image_gray64,
|
||||
image_gray64s,
|
||||
image_gray64f>;
|
||||
|
||||
// Forward declaring
|
||||
struct image_any;
|
||||
|
|
|
@ -38,12 +38,33 @@ MAPNIK_DECL T image_cast(image_rgba8 const&, double offset = 0.0, double scaling
|
|||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray8 const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray8s const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray16 const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray16s const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32 const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32s const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32f const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64 const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64s const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64f const&, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
MAPNIK_DECL image_any image_cast(image_any const&, image_dtype type, double offset = 0.0, double scaling = 1.0);
|
||||
|
||||
} // end mapnik ns
|
||||
|
|
|
@ -60,6 +60,17 @@ struct agg_scaling_traits<image_gray8>
|
|||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray8s>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray8_pre;
|
||||
using color_type = agg::gray8;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray16>
|
||||
{
|
||||
|
@ -71,6 +82,39 @@ struct agg_scaling_traits<image_gray16>
|
|||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray16s>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray16_pre;
|
||||
using color_type = agg::gray16;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray32>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray32_pre;
|
||||
using color_type = agg::gray32;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray32s>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray32_pre;
|
||||
using color_type = agg::gray32;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray32f>
|
||||
{
|
||||
|
@ -82,6 +126,39 @@ struct agg_scaling_traits<image_gray32f>
|
|||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray64>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray32_pre;
|
||||
using color_type = agg::gray32;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray64s>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray32_pre;
|
||||
using color_type = agg::gray32;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct agg_scaling_traits<image_gray64f>
|
||||
{
|
||||
using pixfmt_pre = agg::pixfmt_gray32_pre;
|
||||
using color_type = agg::gray32;
|
||||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
using img_src_type = agg::image_accessor_clone<pixfmt_pre>;
|
||||
using span_image_filter = agg::span_image_filter_gray_nn<img_src_type,interpolator_type>;
|
||||
using span_image_resample_affine = agg::span_image_resample_gray_affine<img_src_type>;
|
||||
};
|
||||
|
||||
template <typename Filter>
|
||||
void set_scaling_method(Filter & filter, scaling_method_e scaling_method, double filter_factor)
|
||||
{
|
||||
|
|
|
@ -110,30 +110,54 @@ MAPNIK_DECL void save_to_stream
|
|||
std::string const& type
|
||||
);
|
||||
|
||||
// PREMULTIPLY ALPHA
|
||||
MAPNIK_DECL bool premultiply_alpha(image_any & image);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL bool premultiply_alpha(T & image);
|
||||
|
||||
// DEMULTIPLY ALPHA
|
||||
MAPNIK_DECL bool demultiply_alpha(image_any & image);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL bool demultiply_alpha(T & image);
|
||||
|
||||
// SET PREMULTIPLIED ALPHA
|
||||
MAPNIK_DECL void set_premultiplied_alpha(image_any & image, bool status);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_premultiplied_alpha(T & image, bool status);
|
||||
|
||||
// IS SOLID
|
||||
MAPNIK_DECL bool is_solid (image_any const& image);
|
||||
MAPNIK_DECL bool is_solid (image_view_any const& image);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL bool is_solid (T const& image);
|
||||
|
||||
// SET ALPHA
|
||||
MAPNIK_DECL void set_alpha (image_any & image, float opacity);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_alpha (T & image, float opacity);
|
||||
|
||||
// SET GRAYSCALE TO ALPHA
|
||||
MAPNIK_DECL void set_grayscale_to_alpha (image_any & image);
|
||||
MAPNIK_DECL void set_grayscale_to_alpha (image_any & image, color const& c);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_grayscale_to_alpha (T & image);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_grayscale_to_alpha (T & image, color const& c);
|
||||
|
||||
// SET COLOR TO ALPHA
|
||||
MAPNIK_DECL void set_color_to_alpha (image_any & image, color const& c);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_color_to_alpha (T & image, color const& c);
|
||||
|
||||
// FILL
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_any & data, T const&);
|
||||
|
||||
|
@ -143,24 +167,53 @@ MAPNIK_DECL void fill (image_rgba8 & data, T const&);
|
|||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray8 & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray8s & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray16 & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray16s & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray32 & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray32s & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray32f & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray64 & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray64s & data, T const&);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void fill (image_gray64f & data, T const&);
|
||||
|
||||
// SET RECTANGLE
|
||||
MAPNIK_DECL void set_rectangle (image_any & dst, image_any const& src, int x = 0, int y = 0);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_rectangle (T & dst, T const& src, int x = 0, int y = 0);
|
||||
|
||||
// CHECK BOUNDS
|
||||
template <typename T>
|
||||
MAPNIK_DECL bool check_bounds (T const& data, std::size_t x, std::size_t y)
|
||||
{
|
||||
return (x < static_cast<int>(data.width()) && y < static_cast<int>(data.height()));
|
||||
}
|
||||
|
||||
// COMPOSITE_PIXEL
|
||||
MAPNIK_DECL void composite_pixel(image_any & data, unsigned op, int x, int y, unsigned c, unsigned cover, double opacity );
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void composite_pixel(T & data, unsigned op, int x, int y, unsigned c, unsigned cover, double opacity );
|
||||
|
||||
// SET PIXEL
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_any & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
|
@ -170,12 +223,34 @@ MAPNIK_DECL void set_pixel(image_rgba8 & data, std::size_t x, std::size_t y, T c
|
|||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray8 & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray8s & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray16 & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray16s & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray32 & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray32s & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray32f & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray64 & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray64s & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL void set_pixel(image_gray64f & data, std::size_t x, std::size_t y, T const& val);
|
||||
|
||||
// GET PIXEL
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_any const& data, std::size_t x, std::size_t y);
|
||||
|
||||
|
@ -188,16 +263,73 @@ MAPNIK_DECL T get_pixel(image_rgba8 const& data, std::size_t x, std::size_t y);
|
|||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray8 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray8s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray16 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray16s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray32 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray32s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray32f const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray64 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray64s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_gray64f const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_rgba8 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray8 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray8s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray16 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray16s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray32 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray32s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray32f const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray64 const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray64s const& data, std::size_t x, std::size_t y);
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T get_pixel(image_view_gray64f const& data, std::size_t x, std::size_t y);
|
||||
|
||||
// VIEW TO STRING
|
||||
MAPNIK_DECL void view_to_string (image_view_any const& view, std::ostringstream & ss);
|
||||
|
||||
// CREATE VIEW
|
||||
MAPNIK_DECL image_view_any create_view (image_any const& data, unsigned x, unsigned y, unsigned w, unsigned h);
|
||||
|
||||
// COMPARE
|
||||
template <typename T>
|
||||
MAPNIK_DECL unsigned compare(T const& im1, T const& im2, double threshold = 0, bool alpha = true);
|
||||
|
||||
|
@ -277,83 +409,6 @@ void add_border(T & image)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
extern template MAPNIK_DECL void save_to_file<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_any>(image_any const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_any>(image_any const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_any>(image_any const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_any>(image_any const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view_any>(image_view_any const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view_any>(image_view_any const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view_any>(image_view_any const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view_any>(image_view_any const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_rgba8>(image_rgba8 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_any>(image_any const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_any>(image_any const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view_any> (image_view_any const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view_any> (image_view_any const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
|
||||
template MAPNIK_DECL void save_to_stream<image_rgba8>(
|
||||
|
|
|
@ -31,6 +31,7 @@ template <typename T>
|
|||
class image_view
|
||||
{
|
||||
public:
|
||||
using pixel = typename T::pixel;
|
||||
using pixel_type = typename T::pixel_type;
|
||||
static constexpr std::size_t pixel_size = sizeof(pixel_type);
|
||||
|
||||
|
@ -141,8 +142,15 @@ private:
|
|||
|
||||
using image_view_rgba8 = image_view<image_rgba8>;
|
||||
using image_view_gray8 = image_view<image_gray8>;
|
||||
using image_view_gray8s = image_view<image_gray8s>;
|
||||
using image_view_gray16 = image_view<image_gray16>;
|
||||
using image_view_gray16s = image_view<image_gray16s>;
|
||||
using image_view_gray32 = image_view<image_gray32>;
|
||||
using image_view_gray32s = image_view<image_gray32s>;
|
||||
using image_view_gray32f = image_view<image_gray32f>;
|
||||
using image_view_gray64 = image_view<image_gray64>;
|
||||
using image_view_gray64s = image_view<image_gray64s>;
|
||||
using image_view_gray64f = image_view<image_gray64f>;
|
||||
|
||||
} // end ns
|
||||
|
||||
|
|
|
@ -30,8 +30,15 @@ namespace mapnik {
|
|||
|
||||
using image_view_base = util::variant<image_view_rgba8,
|
||||
image_view_gray8,
|
||||
image_view_gray8s,
|
||||
image_view_gray16,
|
||||
image_view_gray32f>;
|
||||
image_view_gray16s,
|
||||
image_view_gray32,
|
||||
image_view_gray32s,
|
||||
image_view_gray32f,
|
||||
image_view_gray64,
|
||||
image_view_gray64s,
|
||||
image_view_gray64f>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
|
41
include/mapnik/pixel_types.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_PIXEL_TYPES_HPP
|
||||
#define MAPNIK_PIXEL_TYPES_HPP
|
||||
|
||||
// std
|
||||
#include <cstdint>
|
||||
|
||||
struct rgba8_t { using type = std::uint32_t; };
|
||||
struct gray8_t { using type = std::uint8_t; };
|
||||
struct gray8s_t { using type = std::int8_t; };
|
||||
struct gray16_t { using type = std::uint16_t; };
|
||||
struct gray16s_t { using type = std::int16_t; };
|
||||
struct gray32_t { using type = std::uint32_t; };
|
||||
struct gray32s_t { using type = std::int32_t; };
|
||||
struct gray32f_t { using type = float; };
|
||||
struct gray64_t { using type = std::uint64_t; };
|
||||
struct gray64s_t { using type = std::int64_t; };
|
||||
struct gray64f_t { using type = double; };
|
||||
|
||||
#endif // MAPNIK_PIXEL_TYPES_HPP
|
|
@ -152,8 +152,15 @@ struct raster_marker_render_thunk : util::noncopyable
|
|||
|
||||
template struct raster_marker_render_thunk<image_rgba8>;
|
||||
template struct raster_marker_render_thunk<image_gray8>;
|
||||
template struct raster_marker_render_thunk<image_gray8s>;
|
||||
template struct raster_marker_render_thunk<image_gray16>;
|
||||
template struct raster_marker_render_thunk<image_gray16s>;
|
||||
template struct raster_marker_render_thunk<image_gray32>;
|
||||
template struct raster_marker_render_thunk<image_gray32s>;
|
||||
template struct raster_marker_render_thunk<image_gray32f>;
|
||||
template struct raster_marker_render_thunk<image_gray64>;
|
||||
template struct raster_marker_render_thunk<image_gray64s>;
|
||||
template struct raster_marker_render_thunk<image_gray64f>;
|
||||
|
||||
using helper_ptr = std::unique_ptr<text_symbolizer_helper>;
|
||||
|
||||
|
@ -186,8 +193,15 @@ struct text_render_thunk : util::noncopyable
|
|||
using render_thunk = util::variant<vector_marker_render_thunk,
|
||||
raster_marker_render_thunk<image_rgba8>,
|
||||
raster_marker_render_thunk<image_gray8>,
|
||||
raster_marker_render_thunk<image_gray8s>,
|
||||
raster_marker_render_thunk<image_gray16>,
|
||||
raster_marker_render_thunk<image_gray16s>,
|
||||
raster_marker_render_thunk<image_gray32>,
|
||||
raster_marker_render_thunk<image_gray32s>,
|
||||
raster_marker_render_thunk<image_gray32f>,
|
||||
raster_marker_render_thunk<image_gray64>,
|
||||
raster_marker_render_thunk<image_gray64s>,
|
||||
raster_marker_render_thunk<image_gray64f>,
|
||||
text_render_thunk>;
|
||||
using render_thunk_ptr = std::unique_ptr<render_thunk>;
|
||||
using render_thunk_list = std::list<render_thunk_ptr>;
|
||||
|
|
40
include/mapnik/sse.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_SSE_HPP
|
||||
#define MAPNIK_SSE_HPP
|
||||
|
||||
#include <emmintrin.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#define ROUND_DOWN(x, s) ((x) & ~((s)-1))
|
||||
|
||||
typedef union
|
||||
{
|
||||
__m128i v;
|
||||
int32_t i32[4];
|
||||
uint32_t u32[4];
|
||||
uint16_t u16[8];
|
||||
uint8_t u8[16];
|
||||
} m128_int;
|
||||
|
||||
#endif // MAPNIK_SSE_HPP
|
|
@ -217,6 +217,75 @@ struct tag_setter
|
|||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray64 const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 64);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray64s const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 64);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray64f const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 64);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_FLOATINGPOINT);
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray32 const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 32);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray32s const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 32);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray32f const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
|
@ -244,6 +313,20 @@ struct tag_setter
|
|||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray16s const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 16);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray8 const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
|
@ -258,6 +341,20 @@ struct tag_setter
|
|||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_gray8s const&) const
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
|
||||
TIFFSetField(output_, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(output_, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
if (config_.compression == COMPRESSION_DEFLATE
|
||||
|| config_.compression == COMPRESSION_ADOBE_DEFLATE
|
||||
|| config_.compression == COMPRESSION_LZW)
|
||||
{
|
||||
TIFFSetField(output_, TIFFTAG_PREDICTOR, PREDICTOR_HORIZONTAL);
|
||||
|
||||
}
|
||||
}
|
||||
inline void operator() (image_null const&) const
|
||||
{
|
||||
// Assume this would be null type
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/pixel_types.hpp>
|
||||
|
||||
// icu
|
||||
#include <unicode/uversion.h> // for U_NAMESPACE_QUALIFIER
|
||||
|
@ -43,8 +44,10 @@ namespace mapnik {
|
|||
#ifdef BIGINT
|
||||
//using value_integer = boost::long_long_type;
|
||||
using value_integer = long long;
|
||||
using value_integer_pixel = gray64s_t;
|
||||
#else
|
||||
using value_integer = int;
|
||||
using value_integer_pixel = gray32s_t;
|
||||
#endif
|
||||
|
||||
using value_double = double;
|
||||
|
|
|
@ -77,7 +77,7 @@ inline int import_image(T2 const& im_in,
|
|||
WebPPicture & pic,
|
||||
bool alpha)
|
||||
{
|
||||
image<typename T2::pixel_type> const& data = im_in.data();
|
||||
image<typename T2::pixel> const& data = im_in.data();
|
||||
int stride = sizeof(typename T2::pixel_type) * im_in.width();
|
||||
if (data.width() == im_in.width() &&
|
||||
data.height() == im_in.height())
|
||||
|
|
|
@ -203,29 +203,95 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Reading band=" << band_;
|
||||
if (band_ > 0) // we are querying a single band
|
||||
{
|
||||
mapnik::image_gray16 image(im_width, im_height);
|
||||
image.set(std::numeric_limits<std::int16_t>::max());
|
||||
GDALRasterBand * band = dataset_.GetRasterBand(band_);
|
||||
if (band_ > nbands_)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "GDAL Plugin: " << band_ << " is an invalid band, dataset only has " << nbands_ << "bands";
|
||||
throw datasource_exception(s.str());
|
||||
}
|
||||
|
||||
GDALRasterBand * band = dataset_.GetRasterBand(band_);
|
||||
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
|
||||
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||
image.getData(), image.width(), image.height(),
|
||||
GDT_Int16, 0, 0);
|
||||
if (raster_io_error == CE_Failure)
|
||||
GDALDataType band_type = band->GetRasterDataType();
|
||||
switch (band_type)
|
||||
{
|
||||
throw datasource_exception(CPLGetLastErrorMsg());
|
||||
case GDT_Byte:
|
||||
{
|
||||
mapnik::image_gray8 image(im_width, im_height);
|
||||
image.set(std::numeric_limits<std::uint8_t>::max());
|
||||
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
|
||||
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||
image.getData(), image.width(), image.height(),
|
||||
GDT_Byte, 0, 0);
|
||||
if (raster_io_error == CE_Failure)
|
||||
{
|
||||
throw datasource_exception(CPLGetLastErrorMsg());
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
|
||||
// set nodata value to be used in raster colorizer
|
||||
if (nodata_value_) raster->set_nodata(*nodata_value_);
|
||||
else raster->set_nodata(raster_nodata);
|
||||
feature->set_raster(raster);
|
||||
break;
|
||||
}
|
||||
case GDT_Float64:
|
||||
case GDT_Float32:
|
||||
{
|
||||
mapnik::image_gray32f image(im_width, im_height);
|
||||
image.set(std::numeric_limits<float>::max());
|
||||
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
|
||||
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||
image.getData(), image.width(), image.height(),
|
||||
GDT_Float32, 0, 0);
|
||||
if (raster_io_error == CE_Failure)
|
||||
{
|
||||
throw datasource_exception(CPLGetLastErrorMsg());
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
|
||||
// set nodata value to be used in raster colorizer
|
||||
if (nodata_value_) raster->set_nodata(*nodata_value_);
|
||||
else raster->set_nodata(raster_nodata);
|
||||
feature->set_raster(raster);
|
||||
break;
|
||||
}
|
||||
case GDT_UInt16:
|
||||
{
|
||||
mapnik::image_gray16 image(im_width, im_height);
|
||||
image.set(std::numeric_limits<std::uint16_t>::max());
|
||||
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
|
||||
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||
image.getData(), image.width(), image.height(),
|
||||
GDT_UInt16, 0, 0);
|
||||
if (raster_io_error == CE_Failure)
|
||||
{
|
||||
throw datasource_exception(CPLGetLastErrorMsg());
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
|
||||
// set nodata value to be used in raster colorizer
|
||||
if (nodata_value_) raster->set_nodata(*nodata_value_);
|
||||
else raster->set_nodata(raster_nodata);
|
||||
feature->set_raster(raster);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case GDT_Int16:
|
||||
{
|
||||
mapnik::image_gray16s image(im_width, im_height);
|
||||
image.set(std::numeric_limits<std::int16_t>::max());
|
||||
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
|
||||
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||
image.getData(), image.width(), image.height(),
|
||||
GDT_Int16, 0, 0);
|
||||
if (raster_io_error == CE_Failure)
|
||||
{
|
||||
throw datasource_exception(CPLGetLastErrorMsg());
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
|
||||
// set nodata value to be used in raster colorizer
|
||||
if (nodata_value_) raster->set_nodata(*nodata_value_);
|
||||
else raster->set_nodata(raster_nodata);
|
||||
feature->set_raster(raster);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
|
||||
// set nodata value to be used in raster colorizer
|
||||
if (nodata_value_) raster->set_nodata(*nodata_value_);
|
||||
else raster->set_nodata(raster_nodata);
|
||||
feature->set_raster(raster);
|
||||
}
|
||||
else // working with all bands
|
||||
{
|
||||
|
|
|
@ -44,17 +44,17 @@ namespace mapnik
|
|||
{
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
template class feature_style_processor<cairo_renderer<cairo_ptr> >;
|
||||
template class MAPNIK_DECL feature_style_processor<cairo_renderer<cairo_ptr> >;
|
||||
#endif
|
||||
|
||||
#if defined(SVG_RENDERER)
|
||||
template class feature_style_processor<svg_renderer<std::ostream_iterator<char> > >;
|
||||
template class MAPNIK_DECL feature_style_processor<svg_renderer<std::ostream_iterator<char> > >;
|
||||
#endif
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
template class feature_style_processor<grid_renderer<grid> >;
|
||||
template class MAPNIK_DECL feature_style_processor<grid_renderer<grid> >;
|
||||
#endif
|
||||
|
||||
template class feature_style_processor<agg_renderer<image_rgba8> >;
|
||||
template class MAPNIK_DECL feature_style_processor<agg_renderer<image_rgba8> >;
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace mapnik
|
|||
{
|
||||
|
||||
template <typename T>
|
||||
const typename hit_grid<T>::value_type hit_grid<T>::base_mask = std::numeric_limits<T>::min();
|
||||
const typename hit_grid<T>::value_type hit_grid<T>::base_mask = std::numeric_limits<typename T::type>::min();
|
||||
|
||||
template <typename T>
|
||||
hit_grid<T>::hit_grid(int width, int height, std::string const& key, unsigned int resolution)
|
||||
|
@ -146,7 +146,7 @@ void hit_grid<T>::add_feature(mapnik::feature_impl const& feature)
|
|||
}
|
||||
|
||||
|
||||
template class hit_grid<mapnik::value_integer>;
|
||||
template class MAPNIK_DECL hit_grid<mapnik::value_integer_pixel>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_impl const& feature, pixel_
|
|||
pixmap_.add_feature(feature);
|
||||
}
|
||||
|
||||
template class grid_renderer<grid>;
|
||||
template class MAPNIK_DECL grid_renderer<grid>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,21 @@ MAPNIK_DECL T image_cast(image_gray8 const& data, double offset, double scaling)
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray8s const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray16 const& data, double offset, double scaling)
|
||||
{
|
||||
|
@ -192,6 +207,51 @@ MAPNIK_DECL T image_cast(image_gray16 const& data, double offset, double scaling
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray16s const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32 const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32s const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray32f const& data, double offset, double scaling)
|
||||
{
|
||||
|
@ -207,6 +267,51 @@ MAPNIK_DECL T image_cast(image_gray32f const& data, double offset, double scalin
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64 const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64s const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MAPNIK_DECL T image_cast(image_gray64f const& data, double offset, double scaling)
|
||||
{
|
||||
if (offset == 0.0 && scaling == 1.0 && data.get_offset() == 0.0 && data.get_scaling() == 1.0)
|
||||
{
|
||||
detail::visitor_image_cast<T> visit;
|
||||
return visit(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::visitor_image_cast_so<T> visit(offset, scaling);
|
||||
return visit(data);
|
||||
}
|
||||
}
|
||||
|
||||
MAPNIK_DECL image_any image_cast(image_any const& data, image_dtype type, double offset, double scaling)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -215,10 +320,24 @@ MAPNIK_DECL image_any image_cast(image_any const& data, image_dtype type, double
|
|||
return image_any(std::move(image_cast<image_rgba8>(data, offset, scaling)));
|
||||
case image_dtype_gray8:
|
||||
return image_any(std::move(image_cast<image_gray8>(data, offset, scaling)));
|
||||
case image_dtype_gray8s:
|
||||
return image_any(std::move(image_cast<image_gray8s>(data, offset, scaling)));
|
||||
case image_dtype_gray16:
|
||||
return image_any(std::move(image_cast<image_gray16>(data, offset, scaling)));
|
||||
case image_dtype_gray16s:
|
||||
return image_any(std::move(image_cast<image_gray16s>(data, offset, scaling)));
|
||||
case image_dtype_gray32:
|
||||
return image_any(std::move(image_cast<image_gray32>(data, offset, scaling)));
|
||||
case image_dtype_gray32s:
|
||||
return image_any(std::move(image_cast<image_gray32s>(data, offset, scaling)));
|
||||
case image_dtype_gray32f:
|
||||
return image_any(std::move(image_cast<image_gray32f>(data, offset, scaling)));
|
||||
case image_dtype_gray64:
|
||||
return image_any(std::move(image_cast<image_gray64>(data, offset, scaling)));
|
||||
case image_dtype_gray64s:
|
||||
return image_any(std::move(image_cast<image_gray64s>(data, offset, scaling)));
|
||||
case image_dtype_gray64f:
|
||||
return image_any(std::move(image_cast<image_gray64f>(data, offset, scaling)));
|
||||
case image_dtype_null:
|
||||
throw std::runtime_error("Can not cast a null image");
|
||||
}
|
||||
|
|
|
@ -171,10 +171,30 @@ template MAPNIK_DECL void scale_image_agg(image_rgba8 &, image_rgba8 const&, sca
|
|||
template MAPNIK_DECL void scale_image_agg(image_gray8 &, image_gray8 const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray8s &, image_gray8s const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray16 &, image_gray16 const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray16s &, image_gray16s const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray32 &, image_gray32 const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray32s &, image_gray32s const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray32f &, image_gray32f const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray64 &, image_gray64 const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray64s &, image_gray64s const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
|
||||
template MAPNIK_DECL void scale_image_agg(image_gray64f &, image_gray64f const&, scaling_method_e,
|
||||
double, double , double, double , double);
|
||||
}
|
||||
|
|
1338
src/image_util.cpp
|
@ -88,11 +88,27 @@ void jpeg_saver::operator() (T const& image) const
|
|||
throw ImageWriterException("Mapnik does not support jpeg grayscale images");
|
||||
}
|
||||
|
||||
template void jpeg_saver::operator() (image_gray8 const& image) const;
|
||||
template void jpeg_saver::operator() (image_gray16 const& image) const;
|
||||
template void jpeg_saver::operator() (image_gray32f const& image) const;
|
||||
template void jpeg_saver::operator() (image_view_gray8 const& image) const;
|
||||
template void jpeg_saver::operator() (image_view_gray16 const& image) const;
|
||||
template void jpeg_saver::operator() (image_view_gray32f const& image) const;
|
||||
template void jpeg_saver::operator()<image_rgba8> (image_rgba8 const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray8> (image_gray8 const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray8s> (image_gray8s const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray16> (image_gray16 const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray16s> (image_gray16s const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray32> (image_gray32 const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray32s> (image_gray32s const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray32f> (image_gray32f const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray64> (image_gray64 const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray64s> (image_gray64s const& image) const;
|
||||
template void jpeg_saver::operator()<image_gray64f> (image_gray64f const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray8> (image_view_gray8 const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray8s> (image_view_gray8s const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray16> (image_view_gray16 const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray16s> (image_view_gray16s const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray32> (image_view_gray32 const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray32s> (image_view_gray32s const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray32f> (image_view_gray32f const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray64> (image_view_gray64 const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray64s> (image_view_gray64s const& image) const;
|
||||
template void jpeg_saver::operator()<image_view_gray64f> (image_view_gray64f const& image) const;
|
||||
|
||||
} // end ns
|
||||
|
|
|
@ -308,17 +308,49 @@ void png_saver_pal::operator() (T const& image) const
|
|||
#endif
|
||||
}
|
||||
|
||||
template void png_saver::operator() (image_gray8 const& image) const;
|
||||
template void png_saver::operator() (image_gray16 const& image) const;
|
||||
template void png_saver::operator() (image_gray32f const& image) const;
|
||||
template void png_saver::operator() (image_view_gray8 const& image) const;
|
||||
template void png_saver::operator() (image_view_gray16 const& image) const;
|
||||
template void png_saver::operator() (image_view_gray32f const& image) const;
|
||||
template void png_saver_pal::operator() (image_gray8 const& image) const;
|
||||
template void png_saver_pal::operator() (image_gray16 const& image) const;
|
||||
template void png_saver_pal::operator() (image_gray32f const& image) const;
|
||||
template void png_saver_pal::operator() (image_view_gray8 const& image) const;
|
||||
template void png_saver_pal::operator() (image_view_gray16 const& image) const;
|
||||
template void png_saver_pal::operator() (image_view_gray32f const& image) const;
|
||||
template void png_saver::operator()<image_rgba8> (image_rgba8 const& image) const;
|
||||
template void png_saver::operator()<image_gray8> (image_gray8 const& image) const;
|
||||
template void png_saver::operator()<image_gray8s> (image_gray8s const& image) const;
|
||||
template void png_saver::operator()<image_gray16> (image_gray16 const& image) const;
|
||||
template void png_saver::operator()<image_gray16s> (image_gray16s const& image) const;
|
||||
template void png_saver::operator()<image_gray32> (image_gray32 const& image) const;
|
||||
template void png_saver::operator()<image_gray32s> (image_gray32s const& image) const;
|
||||
template void png_saver::operator()<image_gray32f> (image_gray32f const& image) const;
|
||||
template void png_saver::operator()<image_gray64> (image_gray64 const& image) const;
|
||||
template void png_saver::operator()<image_gray64s> (image_gray64s const& image) const;
|
||||
template void png_saver::operator()<image_gray64f> (image_gray64f const& image) const;
|
||||
template void png_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const;
|
||||
template void png_saver::operator()<image_view_gray8> (image_view_gray8 const& image) const;
|
||||
template void png_saver::operator()<image_view_gray8s> (image_view_gray8s const& image) const;
|
||||
template void png_saver::operator()<image_view_gray16> (image_view_gray16 const& image) const;
|
||||
template void png_saver::operator()<image_view_gray16s> (image_view_gray16s const& image) const;
|
||||
template void png_saver::operator()<image_view_gray32> (image_view_gray32 const& image) const;
|
||||
template void png_saver::operator()<image_view_gray32s> (image_view_gray32s const& image) const;
|
||||
template void png_saver::operator()<image_view_gray32f> (image_view_gray32f const& image) const;
|
||||
template void png_saver::operator()<image_view_gray64> (image_view_gray64 const& image) const;
|
||||
template void png_saver::operator()<image_view_gray64s> (image_view_gray64s const& image) const;
|
||||
template void png_saver::operator()<image_view_gray64f> (image_view_gray64f const& image) const;
|
||||
template void png_saver_pal::operator()<image_rgba8> (image_rgba8 const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray8> (image_gray8 const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray8s> (image_gray8s const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray16> (image_gray16 const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray16s> (image_gray16s const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray32> (image_gray32 const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray32s> (image_gray32s const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray32f> (image_gray32f const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray64> (image_gray64 const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray64s> (image_gray64s const& image) const;
|
||||
template void png_saver_pal::operator()<image_gray64f> (image_gray64f const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_rgba8> (image_view_rgba8 const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray8> (image_view_gray8 const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray8s> (image_view_gray8s const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray16> (image_view_gray16 const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray16s> (image_view_gray16s const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray32> (image_view_gray32 const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray32s> (image_view_gray32s const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray32f> (image_view_gray32f const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray64> (image_view_gray64 const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray64s> (image_view_gray64s const& image) const;
|
||||
template void png_saver_pal::operator()<image_view_gray64f> (image_view_gray64f const& image) const;
|
||||
|
||||
} // end ns
|
||||
|
|
|
@ -181,13 +181,27 @@ void tiff_saver::operator() (T const& image) const
|
|||
#endif
|
||||
}
|
||||
|
||||
template void tiff_saver::operator() (image_rgba8 const& image) const;
|
||||
template void tiff_saver::operator() (image_gray8 const& image) const;
|
||||
template void tiff_saver::operator() (image_gray16 const& image) const;
|
||||
template void tiff_saver::operator() (image_gray32f const& image) const;
|
||||
template void tiff_saver::operator() (image_view_rgba8 const& image) const;
|
||||
template void tiff_saver::operator() (image_view_gray8 const& image) const;
|
||||
template void tiff_saver::operator() (image_view_gray16 const& image) const;
|
||||
template void tiff_saver::operator() (image_view_gray32f const& image) const;
|
||||
template void tiff_saver::operator()<image_rgba8> (image_rgba8 const& image) const;
|
||||
template void tiff_saver::operator()<image_gray8> (image_gray8 const& image) const;
|
||||
template void tiff_saver::operator()<image_gray8s> (image_gray8s const& image) const;
|
||||
template void tiff_saver::operator()<image_gray16> (image_gray16 const& image) const;
|
||||
template void tiff_saver::operator()<image_gray16s> (image_gray16s const& image) const;
|
||||
template void tiff_saver::operator()<image_gray32> (image_gray32 const& image) const;
|
||||
template void tiff_saver::operator()<image_gray32s> (image_gray32s const& image) const;
|
||||
template void tiff_saver::operator()<image_gray32f> (image_gray32f const& image) const;
|
||||
template void tiff_saver::operator()<image_gray64> (image_gray64 const& image) const;
|
||||
template void tiff_saver::operator()<image_gray64s> (image_gray64s const& image) const;
|
||||
template void tiff_saver::operator()<image_gray64f> (image_gray64f const& image) const;
|
||||
template void tiff_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray8> (image_view_gray8 const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray8s> (image_view_gray8s const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray16> (image_view_gray16 const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray16s> (image_view_gray16s const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray32> (image_view_gray32 const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray32s> (image_view_gray32s const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray32f> (image_view_gray32f const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray64> (image_view_gray64 const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray64s> (image_view_gray64s const& image) const;
|
||||
template void tiff_saver::operator()<image_view_gray64f> (image_view_gray64f const& image) const;
|
||||
|
||||
} // end ns
|
||||
|
|
|
@ -379,11 +379,25 @@ void webp_saver::operator() (T const& image) const
|
|||
|
||||
template void webp_saver::operator()<image_rgba8> (image_rgba8 const& image) const;
|
||||
template void webp_saver::operator()<image_gray8> (image_gray8 const& image) const;
|
||||
template void webp_saver::operator()<image_gray8s> (image_gray8s const& image) const;
|
||||
template void webp_saver::operator()<image_gray16> (image_gray16 const& image) const;
|
||||
template void webp_saver::operator()<image_gray16s> (image_gray16s const& image) const;
|
||||
template void webp_saver::operator()<image_gray32> (image_gray32 const& image) const;
|
||||
template void webp_saver::operator()<image_gray32s> (image_gray32s const& image) const;
|
||||
template void webp_saver::operator()<image_gray32f> (image_gray32f const& image) const;
|
||||
template void webp_saver::operator()<image_gray64> (image_gray64 const& image) const;
|
||||
template void webp_saver::operator()<image_gray64s> (image_gray64s const& image) const;
|
||||
template void webp_saver::operator()<image_gray64f> (image_gray64f const& image) const;
|
||||
template void webp_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray8> (image_view_gray8 const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray8s> (image_view_gray8s const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray16> (image_view_gray16 const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray16s> (image_view_gray16s const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray32> (image_view_gray32 const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray32s> (image_view_gray32s const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray32f> (image_view_gray32f const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray64> (image_view_gray64 const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray64s> (image_view_gray64s const& image) const;
|
||||
template void webp_saver::operator()<image_view_gray64f> (image_view_gray64f const& image) const;
|
||||
|
||||
} // end ns
|
||||
|
|
|
@ -289,11 +289,32 @@ unsigned raster_colorizer::get_color(float value) const
|
|||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray8 const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray8s const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray16 const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray16s const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray32 const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray32s const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray32f const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray64 const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray64s const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
template void raster_colorizer::colorize(image_rgba8 & out, image_gray64f const& in,
|
||||
boost::optional<double>const& nodata,
|
||||
feature_impl const& f) const;
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,16 @@ raster_marker_render_thunk<image_gray8>::raster_marker_render_thunk(image_gray8
|
|||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray8s>::raster_marker_render_thunk(image_gray8s & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray16>::raster_marker_render_thunk(image_gray16 & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
|
@ -69,6 +79,36 @@ raster_marker_render_thunk<image_gray16>::raster_marker_render_thunk(image_gray1
|
|||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray16s>::raster_marker_render_thunk(image_gray16s & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray32>::raster_marker_render_thunk(image_gray32 & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray32s>::raster_marker_render_thunk(image_gray32s & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray32f>::raster_marker_render_thunk(image_gray32f & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
|
@ -79,6 +119,36 @@ raster_marker_render_thunk<image_gray32f>::raster_marker_render_thunk(image_gray
|
|||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray64>::raster_marker_render_thunk(image_gray64 & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray64s>::raster_marker_render_thunk(image_gray64s & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
template <>
|
||||
raster_marker_render_thunk<image_gray64f>::raster_marker_render_thunk(image_gray64f & src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels)
|
||||
: src_(src), tr_(marker_trans), opacity_(opacity), comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
text_render_thunk::text_render_thunk(helper_ptr && helper,
|
||||
double opacity, composite_mode_e comp_op,
|
||||
halo_rasterizer_enum halo_rasterizer)
|
||||
|
@ -137,6 +207,11 @@ struct visitor_push_thunk
|
|||
opacity_(opacity),
|
||||
comp_op_(comp_op),
|
||||
snap_to_pixels_(snap_to_pixels) {}
|
||||
|
||||
void operator() (image_null &)
|
||||
{
|
||||
throw std::runtime_error("Push thunk does not support null images");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator() (T & data)
|
||||
|
@ -153,12 +228,6 @@ struct visitor_push_thunk
|
|||
bool snap_to_pixels_;
|
||||
};
|
||||
|
||||
template <>
|
||||
void visitor_push_thunk::operator()<image_null> (image_null &)
|
||||
{
|
||||
throw std::runtime_error("Push thunk does not support null images");
|
||||
}
|
||||
|
||||
template <typename Detector, typename RendererContext>
|
||||
struct raster_marker_thunk_dispatch : public raster_markers_dispatch<Detector>
|
||||
{
|
||||
|
|
|
@ -132,6 +132,7 @@ private:
|
|||
std::size_t height_;
|
||||
boost::optional<box2d<double> > bbox_;
|
||||
unsigned bps_;
|
||||
unsigned sample_format_;
|
||||
unsigned photometric_;
|
||||
unsigned bands_;
|
||||
unsigned planar_config_;
|
||||
|
@ -156,6 +157,7 @@ public:
|
|||
image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
|
||||
// methods specific to tiff reader
|
||||
unsigned bits_per_sample() const { return bps_; }
|
||||
unsigned sample_format() const { return sample_format_; }
|
||||
unsigned photometric() const { return photometric_; }
|
||||
bool is_tiled() const { return is_tiled_; }
|
||||
unsigned tile_width() const { return tile_width_; }
|
||||
|
@ -209,6 +211,7 @@ tiff_reader<T>::tiff_reader(std::string const& file_name)
|
|||
width_(0),
|
||||
height_(0),
|
||||
bps_(0),
|
||||
sample_format_(SAMPLEFORMAT_UINT),
|
||||
photometric_(0),
|
||||
bands_(1),
|
||||
planar_config_(PLANARCONFIG_CONTIG),
|
||||
|
@ -232,6 +235,7 @@ tiff_reader<T>::tiff_reader(char const* data, std::size_t size)
|
|||
width_(0),
|
||||
height_(0),
|
||||
bps_(0),
|
||||
sample_format_(SAMPLEFORMAT_UINT),
|
||||
photometric_(0),
|
||||
bands_(1),
|
||||
planar_config_(PLANARCONFIG_CONTIG),
|
||||
|
@ -257,10 +261,12 @@ void tiff_reader<T>::init()
|
|||
if (!tif) throw image_reader_exception("Can't open tiff file");
|
||||
|
||||
TIFFGetField(tif,TIFFTAG_BITSPERSAMPLE,&bps_);
|
||||
TIFFGetField(tif,TIFFTAG_SAMPLEFORMAT,&sample_format_);
|
||||
TIFFGetField(tif,TIFFTAG_PHOTOMETRIC,&photometric_);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &bands_);
|
||||
|
||||
MAPNIK_LOG_DEBUG(tiff_reader) << "bits per sample: " << bps_;
|
||||
MAPNIK_LOG_DEBUG(tiff_reader) << "sample format: " << sample_format_;
|
||||
MAPNIK_LOG_DEBUG(tiff_reader) << "photometric: " << photometric_;
|
||||
MAPNIK_LOG_DEBUG(tiff_reader) << "bands: " << bands_;
|
||||
|
||||
|
@ -491,67 +497,86 @@ image_any tiff_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigne
|
|||
{
|
||||
case 8:
|
||||
{
|
||||
return read_any_gray<image_gray8>(x0, y0, width, height);
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
return read_any_gray<image_gray16>(x0, y0, width, height);
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
return read_any_gray<image_gray32f>(x0, y0, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
// read PHOTOMETRIC_RGB expand using RGBA interface
|
||||
/*
|
||||
case PHOTOMETRIC_RGB:
|
||||
{
|
||||
switch (bps_)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
TIFF* tif = open(stream_);
|
||||
if (tif)
|
||||
switch (sample_format_)
|
||||
{
|
||||
image_rgba8 data(width, height, true, premultiplied_alpha_);
|
||||
std::size_t element_size = sizeof(detail::rgb8);
|
||||
std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1)/element_size;
|
||||
const std::unique_ptr<detail::rgb8[]> scanline(new detail::rgb8[size_to_allocate]);
|
||||
std::ptrdiff_t start_y = y0 - y0 % rows_per_strip_;
|
||||
std::ptrdiff_t end_y = std::min(y0 + height, static_cast<unsigned>(height_));
|
||||
std::ptrdiff_t start_x = x0;
|
||||
std::ptrdiff_t end_x = std::min(x0 + width, static_cast<unsigned>(width_));
|
||||
for (std::size_t y = start_y; y < end_y; ++y)
|
||||
{
|
||||
if (-1 != TIFFReadScanline(tif, scanline.get(), y))
|
||||
{
|
||||
if (y >= y0)
|
||||
{
|
||||
image_rgba8::pixel_type * row = data.getRow(y - y0);
|
||||
std::transform(scanline.get() + start_x, scanline.get() + end_x, row, detail::rgb8_to_rgba8());
|
||||
}
|
||||
}
|
||||
}
|
||||
return image_any(std::move(data));
|
||||
case SAMPLEFORMAT_UINT:
|
||||
{
|
||||
return read_any_gray<image_gray8>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_INT:
|
||||
{
|
||||
return read_any_gray<image_gray8s>(x0, y0, width, height);
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw std::runtime_error("tiff_reader: This sample format is not supported for this bits per sample");
|
||||
}
|
||||
}
|
||||
return image_any();
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
image_rgba8 data(width,height,true,premultiplied_alpha_);
|
||||
read(x0, y0, data);
|
||||
return image_any(std::move(data));
|
||||
switch (sample_format_)
|
||||
{
|
||||
case SAMPLEFORMAT_UINT:
|
||||
{
|
||||
return read_any_gray<image_gray16>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_INT:
|
||||
{
|
||||
return read_any_gray<image_gray16s>(x0, y0, width, height);
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw std::runtime_error("tiff_reader: This sample format is not supported for this bits per sample");
|
||||
}
|
||||
}
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
image_rgba8 data(width,height,true,premultiplied_alpha_);
|
||||
read(x0, y0, data);
|
||||
return image_any(std::move(data));
|
||||
switch (sample_format_)
|
||||
{
|
||||
case SAMPLEFORMAT_UINT:
|
||||
{
|
||||
return read_any_gray<image_gray32>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_INT:
|
||||
{
|
||||
return read_any_gray<image_gray32s>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_IEEEFP:
|
||||
{
|
||||
return read_any_gray<image_gray32f>(x0, y0, width, height);
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw std::runtime_error("tiff_reader: This sample format is not supported for this bits per sample");
|
||||
}
|
||||
}
|
||||
}
|
||||
case 64:
|
||||
{
|
||||
switch (sample_format_)
|
||||
{
|
||||
case SAMPLEFORMAT_UINT:
|
||||
{
|
||||
return read_any_gray<image_gray64>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_INT:
|
||||
{
|
||||
return read_any_gray<image_gray64s>(x0, y0, width, height);
|
||||
}
|
||||
case SAMPLEFORMAT_IEEEFP:
|
||||
{
|
||||
return read_any_gray<image_gray64f>(x0, y0, width, height);
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw std::runtime_error("tiff_reader: This sample format is not supported for this bits per sample");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
default:
|
||||
{
|
||||
//PHOTOMETRIC_PALETTE = 3;
|
||||
|
|
|
@ -70,8 +70,8 @@ MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const&
|
|||
std::size_t mesh_nx = std::ceil(source.width()/double(mesh_size) + 1);
|
||||
std::size_t mesh_ny = std::ceil(source.height()/double(mesh_size) + 1);
|
||||
|
||||
image<double> xs(mesh_nx, mesh_ny);
|
||||
image<double> ys(mesh_nx, mesh_ny);
|
||||
image_gray64f xs(mesh_nx, mesh_ny, false);
|
||||
image_gray64f ys(mesh_nx, mesh_ny, false);
|
||||
|
||||
// Precalculate reprojected mesh
|
||||
for(std::size_t j = 0; j < mesh_ny; ++j)
|
||||
|
|
|
@ -11,22 +11,22 @@ def setup():
|
|||
os.chdir(execution_path('.'))
|
||||
|
||||
def test_compare_rgba8():
|
||||
im = mapnik.Image(2,2,mapnik.ImageType.rgba8)
|
||||
im = mapnik.Image(5,5,mapnik.ImageType.rgba8)
|
||||
im.fill(mapnik.Color(0,0,0,0))
|
||||
eq_(im.compare(im), 0)
|
||||
im2 = mapnik.Image(2,2,mapnik.ImageType.rgba8)
|
||||
im2 = mapnik.Image(5,5,mapnik.ImageType.rgba8)
|
||||
im2.fill(mapnik.Color(0,0,0,0))
|
||||
eq_(im.compare(im2), 0)
|
||||
eq_(im2.compare(im), 0)
|
||||
im2.fill(mapnik.Color(0,0,0,12))
|
||||
eq_(im.compare(im2), 4)
|
||||
eq_(im.compare(im2), 25)
|
||||
eq_(im.compare(im2, 0, False), 0)
|
||||
im3 = mapnik.Image(2,2,mapnik.ImageType.rgba8)
|
||||
im3 = mapnik.Image(5,5,mapnik.ImageType.rgba8)
|
||||
im3.set_pixel(0,0, mapnik.Color(0,0,0,0))
|
||||
im3.set_pixel(0,1, mapnik.Color(1,1,1,1))
|
||||
im3.set_pixel(1,0, mapnik.Color(2,2,2,2))
|
||||
im3.set_pixel(1,1, mapnik.Color(3,3,3,3))
|
||||
eq_(im.compare(im3),3)
|
||||
eq_(im.compare(im3), 3)
|
||||
eq_(im.compare(im3,1),2)
|
||||
eq_(im.compare(im3,2),1)
|
||||
eq_(im.compare(im3,3),0)
|
||||
|
|
|
@ -143,6 +143,9 @@ def test_pixel_underflow():
|
|||
im = mapnik.Image(4,4,mapnik.ImageType.gray8)
|
||||
im.set_pixel(0,0,-1)
|
||||
eq_(im.get_pixel(0,0),0)
|
||||
im = mapnik.Image(4,4,mapnik.ImageType.gray16)
|
||||
im.set_pixel(0,0,-1)
|
||||
eq_(im.get_pixel(0,0),0)
|
||||
|
||||
@raises(IndexError)
|
||||
def test_set_pixel_out_of_range_1():
|
||||
|
|
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8 KiB |
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8 KiB |
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8 KiB |
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |