Intial commit for impl
This commit is contained in:
parent
7a84df012d
commit
bf61a033d3
8 changed files with 778 additions and 473 deletions
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_IMAGE_DATA_HPP
|
||||
#define MAPNIK_IMAGE_DATA_HPP
|
||||
#ifndef MAPNIK_IMAGE_HPP
|
||||
#define MAPNIK_IMAGE_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
|
@ -29,9 +29,7 @@
|
|||
|
||||
// stl
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -116,7 +114,7 @@ struct image_dimensions
|
|||
std::size_t height_;
|
||||
};
|
||||
|
||||
}
|
||||
} // end ns detail
|
||||
|
||||
template <typename T, std::size_t max_size = 65535>
|
||||
class image
|
||||
|
@ -135,192 +133,46 @@ private:
|
|||
bool premultiplied_alpha_;
|
||||
bool painted_;
|
||||
public:
|
||||
image(int width, int height, bool initialize = true, bool premultiplied = false, bool painted = false)
|
||||
: dimensions_(width, height),
|
||||
buffer_(dimensions_.width() * dimensions_.height() * pixel_size),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(0.0),
|
||||
scaling_(1.0),
|
||||
premultiplied_alpha_(premultiplied),
|
||||
painted_(painted)
|
||||
{
|
||||
if (pData_ && initialize) std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), 0);
|
||||
}
|
||||
image();
|
||||
image(int width,
|
||||
int height,
|
||||
bool initialize = true,
|
||||
bool premultiplied = false,
|
||||
bool painted = false);
|
||||
image(image<T> const& rhs);
|
||||
image(image<T> && rhs) noexcept;
|
||||
image<T>& operator=(image<T> rhs);
|
||||
|
||||
image(image<T> const& rhs)
|
||||
: dimensions_(rhs.dimensions_),
|
||||
buffer_(rhs.buffer_),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(rhs.offset_),
|
||||
scaling_(rhs.scaling_),
|
||||
premultiplied_alpha_(rhs.premultiplied_alpha_),
|
||||
painted_(rhs.painted_)
|
||||
{}
|
||||
|
||||
image(image<T> && rhs) noexcept
|
||||
: dimensions_(std::move(rhs.dimensions_)),
|
||||
buffer_(std::move(rhs.buffer_)),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(rhs.offset_),
|
||||
scaling_(rhs.scaling_),
|
||||
premultiplied_alpha_(rhs.premultiplied_alpha_),
|
||||
painted_(rhs.painted_)
|
||||
{
|
||||
rhs.dimensions_ = { 0, 0 };
|
||||
rhs.pData_ = nullptr;
|
||||
}
|
||||
|
||||
image<T>& operator=(image<T> rhs)
|
||||
{
|
||||
swap(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(image<T> & rhs)
|
||||
{
|
||||
std::swap(dimensions_, rhs.dimensions_);
|
||||
std::swap(buffer_, rhs.buffer_);
|
||||
std::swap(offset_, rhs.offset_);
|
||||
std::swap(scaling_, rhs.scaling_);
|
||||
std::swap(premultiplied_alpha_, rhs.premultiplied_alpha_);
|
||||
std::swap(painted_, rhs.painted_);
|
||||
}
|
||||
|
||||
inline pixel_type& operator() (std::size_t i, std::size_t j)
|
||||
{
|
||||
assert(i < dimensions_.width() && j < dimensions_.height());
|
||||
return pData_[j * dimensions_.width() + i];
|
||||
}
|
||||
inline const pixel_type& operator() (std::size_t i, std::size_t j) const
|
||||
{
|
||||
assert(i < dimensions_.width() && j < dimensions_.height());
|
||||
return pData_[j * dimensions_.width() + i];
|
||||
}
|
||||
inline std::size_t width() const
|
||||
{
|
||||
return dimensions_.width();
|
||||
}
|
||||
inline std::size_t height() const
|
||||
{
|
||||
return dimensions_.height();
|
||||
}
|
||||
inline unsigned getSize() const
|
||||
{
|
||||
return dimensions_.height() * dimensions_.width() * pixel_size;
|
||||
}
|
||||
inline unsigned getRowSize() const
|
||||
{
|
||||
return dimensions_.width() * pixel_size;
|
||||
}
|
||||
inline void set(pixel_type const& t)
|
||||
{
|
||||
std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), t);
|
||||
}
|
||||
|
||||
inline const pixel_type* getData() const
|
||||
{
|
||||
return pData_;
|
||||
}
|
||||
|
||||
inline pixel_type* getData()
|
||||
{
|
||||
return pData_;
|
||||
}
|
||||
|
||||
inline const unsigned char* getBytes() const
|
||||
{
|
||||
return buffer_.data();
|
||||
}
|
||||
|
||||
inline unsigned char* getBytes()
|
||||
{
|
||||
return buffer_.data();
|
||||
}
|
||||
|
||||
inline const pixel_type* getRow(std::size_t row) const
|
||||
{
|
||||
return pData_ + row * dimensions_.width();
|
||||
}
|
||||
|
||||
inline const pixel_type* getRow(std::size_t row, std::size_t x0) const
|
||||
{
|
||||
return pData_ + row * dimensions_.width() + x0;
|
||||
}
|
||||
|
||||
inline pixel_type* getRow(std::size_t row)
|
||||
{
|
||||
return pData_ + row * dimensions_.width();
|
||||
}
|
||||
|
||||
inline pixel_type* getRow(std::size_t row, std::size_t x0)
|
||||
{
|
||||
return pData_ + row * dimensions_.width() + x0;
|
||||
}
|
||||
|
||||
inline void setRow(std::size_t row, pixel_type const* buf, std::size_t size)
|
||||
{
|
||||
assert(row < dimensions_.height());
|
||||
assert(size <= dimensions_.width());
|
||||
std::copy(buf, buf + size, pData_ + row * dimensions_.width());
|
||||
}
|
||||
inline void setRow(std::size_t row, std::size_t x0, std::size_t x1, pixel_type const* buf)
|
||||
{
|
||||
assert(row < dimensions_.height());
|
||||
assert ((x1 - x0) <= dimensions_.width() );
|
||||
std::copy(buf, buf + (x1 - x0), pData_ + row * dimensions_.width() + x0);
|
||||
}
|
||||
|
||||
inline double get_offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
inline void set_offset(double set)
|
||||
{
|
||||
offset_ = set;
|
||||
}
|
||||
|
||||
inline double get_scaling() const
|
||||
{
|
||||
return scaling_;
|
||||
}
|
||||
|
||||
inline void set_scaling(double set)
|
||||
{
|
||||
if (set != 0.0)
|
||||
{
|
||||
scaling_ = set;
|
||||
return;
|
||||
}
|
||||
std::clog << "Can not set scaling to 0.0, offset not set." << std::endl;
|
||||
}
|
||||
|
||||
inline bool get_premultiplied() const
|
||||
{
|
||||
return premultiplied_alpha_;
|
||||
}
|
||||
|
||||
inline void set_premultiplied(bool set)
|
||||
{
|
||||
premultiplied_alpha_ = set;
|
||||
}
|
||||
|
||||
inline void painted(bool painted)
|
||||
{
|
||||
painted_ = painted;
|
||||
}
|
||||
|
||||
inline bool painted() const
|
||||
{
|
||||
return painted_;
|
||||
}
|
||||
|
||||
inline image_dtype get_dtype() const
|
||||
{
|
||||
return dtype;
|
||||
}
|
||||
void swap(image<T> & rhs);
|
||||
pixel_type& operator() (std::size_t i, std::size_t j);
|
||||
const pixel_type& operator() (std::size_t i, std::size_t j) const;
|
||||
std::size_t width() const;
|
||||
std::size_t height() const;
|
||||
unsigned getSize() const;
|
||||
unsigned getRowSize() const;
|
||||
void set(pixel_type const& t);
|
||||
const pixel_type* getData() const;
|
||||
pixel_type* getData();
|
||||
const unsigned char* getBytes() const;
|
||||
unsigned char* getBytes();
|
||||
const pixel_type* getRow(std::size_t row) const;
|
||||
const pixel_type* getRow(std::size_t row, std::size_t x0) const;
|
||||
pixel_type* getRow(std::size_t row);
|
||||
pixel_type* getRow(std::size_t row, std::size_t x0);
|
||||
void setRow(std::size_t row, pixel_type const* buf, std::size_t size);
|
||||
void setRow(std::size_t row, std::size_t x0, std::size_t x1, pixel_type const* buf);
|
||||
double get_offset() const;
|
||||
void set_offset(double set);
|
||||
double get_scaling() const;
|
||||
void set_scaling(double set);
|
||||
bool get_premultiplied() const;
|
||||
void set_premultiplied(bool set);
|
||||
void painted(bool painted);
|
||||
bool painted() const;
|
||||
image_dtype get_dtype() const;
|
||||
};
|
||||
|
||||
using image_null = image<null_t>;
|
||||
using image_rgba8 = image<rgba8_t>;
|
||||
using image_gray8 = image<gray8_t>;
|
||||
using image_gray8s = image<gray8s_t>;
|
||||
|
@ -333,6 +185,6 @@ using image_gray64 = image<gray64_t>;
|
|||
using image_gray64s = image<gray64s_t>;
|
||||
using image_gray64f = image<gray64f_t>;
|
||||
|
||||
} // end ns
|
||||
} // end ns mapnik
|
||||
|
||||
#endif // MAPNIK_IMAGE_DATA_HPP
|
||||
#endif // MAPNIK_IMAGE_HPP
|
||||
|
|
|
@ -20,43 +20,14 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_IMAGE_DATA_ANY_HPP
|
||||
#define MAPNIK_IMAGE_DATA_ANY_HPP
|
||||
#ifndef MAPNIK_IMAGE_ANY_HPP
|
||||
#define MAPNIK_IMAGE_ANY_HPP
|
||||
|
||||
#include <mapnik/image.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
struct image_null
|
||||
{
|
||||
using pixel_type = uint8_t;
|
||||
static const image_dtype dtype = image_dtype_null;
|
||||
unsigned char const* getBytes() const { return nullptr; }
|
||||
unsigned char* getBytes() { return nullptr;}
|
||||
unsigned getSize() const { return 0; }
|
||||
unsigned getRowSize() const { return 0; }
|
||||
std::size_t width() const { return 0; }
|
||||
std::size_t height() const { return 0; }
|
||||
bool painted() const { return false; }
|
||||
double get_offset() const { return 0.0; }
|
||||
void set_offset(double) {}
|
||||
image_dtype get_dtype() const { return dtype; }
|
||||
double get_scaling() const { return 1.0; }
|
||||
void set_scaling(double) {}
|
||||
bool get_premultiplied() const { return false; }
|
||||
void set_premultiplied(bool) {}
|
||||
void set(pixel_type const&) { throw std::runtime_error("Can not set values for null image"); }
|
||||
pixel_type& operator() (std::size_t, std::size_t)
|
||||
{
|
||||
throw std::runtime_error("Can not set or get values for null image");
|
||||
}
|
||||
pixel_type const& operator() (std::size_t, std::size_t) const
|
||||
{
|
||||
throw std::runtime_error("Can not set or get values for null image");
|
||||
}
|
||||
};
|
||||
|
||||
using image_base = util::variant<image_null,
|
||||
image_rgba8,
|
||||
image_gray8,
|
||||
|
@ -70,8 +41,36 @@ using image_base = util::variant<image_null,
|
|||
image_gray64s,
|
||||
image_gray64f>;
|
||||
|
||||
// Forward declaring
|
||||
struct image_any;
|
||||
|
||||
struct image_any : image_base
|
||||
{
|
||||
image_any() = default;
|
||||
|
||||
image_any(int width,
|
||||
int height,
|
||||
image_dtype type = image_dtype_rgba8,
|
||||
bool initialize = true,
|
||||
bool premultiplied = false,
|
||||
bool painted = false);
|
||||
|
||||
template <typename T>
|
||||
image_any(T && data) noexcept;
|
||||
|
||||
unsigned char const* getBytes() const;
|
||||
unsigned char* getBytes();
|
||||
std::size_t width() const;
|
||||
std::size_t height() const;
|
||||
bool get_premultiplied() const;
|
||||
bool painted() const;
|
||||
unsigned getSize() const;
|
||||
unsigned getRowSize() const;
|
||||
double get_offset() const;
|
||||
double get_scaling() const;
|
||||
image_dtype get_dtype() const;
|
||||
void set_offset(double val);
|
||||
void set_scaling(double val);
|
||||
};
|
||||
|
||||
image_any create_image_any(int width,
|
||||
int height,
|
||||
image_dtype type = image_dtype_rgba8,
|
||||
|
@ -79,255 +78,6 @@ image_any create_image_any(int width,
|
|||
bool premultiplied = false,
|
||||
bool painted = false);
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct get_bytes_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned char* operator()(T & data)
|
||||
{
|
||||
return data.getBytes();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_dtype_visitor
|
||||
{
|
||||
template <typename T>
|
||||
image_dtype operator()(T & data)
|
||||
{
|
||||
return data.get_dtype();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_bytes_visitor_const
|
||||
{
|
||||
template <typename T>
|
||||
unsigned char const* operator()(T const& data) const
|
||||
{
|
||||
return data.getBytes();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_width_visitor
|
||||
{
|
||||
template <typename T>
|
||||
std::size_t operator()(T const& data) const
|
||||
{
|
||||
return data.width();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_height_visitor
|
||||
{
|
||||
template <typename T>
|
||||
std::size_t operator()(T const& data) const
|
||||
{
|
||||
return data.height();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_premultiplied_visitor
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(T const& data) const
|
||||
{
|
||||
return data.get_premultiplied();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_painted_visitor
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(T const& data) const
|
||||
{
|
||||
return data.painted();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_any_size_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned operator()(T const& data) const
|
||||
{
|
||||
return data.getSize();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_any_row_size_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned operator()(T const& data) const
|
||||
{
|
||||
return data.getRowSize();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_offset_visitor
|
||||
{
|
||||
template <typename T>
|
||||
double operator() (T const& data) const
|
||||
{
|
||||
return data.get_offset();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_scaling_visitor
|
||||
{
|
||||
template <typename T>
|
||||
double operator() (T const& data) const
|
||||
{
|
||||
return data.get_scaling();
|
||||
}
|
||||
};
|
||||
|
||||
struct set_offset_visitor
|
||||
{
|
||||
set_offset_visitor(double val)
|
||||
: val_(val) {}
|
||||
template <typename T>
|
||||
void operator() (T & data)
|
||||
{
|
||||
data.set_offset(val_);
|
||||
}
|
||||
private:
|
||||
double val_;
|
||||
};
|
||||
|
||||
struct set_scaling_visitor
|
||||
{
|
||||
set_scaling_visitor(double val)
|
||||
: val_(val) {}
|
||||
template <typename T>
|
||||
void operator() (T & data)
|
||||
{
|
||||
data.set_scaling(val_);
|
||||
}
|
||||
private:
|
||||
double val_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
struct image_any : image_base
|
||||
{
|
||||
image_any() = default;
|
||||
|
||||
image_any(int width,
|
||||
int height,
|
||||
image_dtype type = image_dtype_rgba8,
|
||||
bool initialize = true,
|
||||
bool premultiplied = false,
|
||||
bool painted = false)
|
||||
: image_base(std::move(create_image_any(width, height, type, initialize, premultiplied, painted))) {}
|
||||
|
||||
template <typename T>
|
||||
image_any(T && data) noexcept
|
||||
: image_base(std::move(data)) {}
|
||||
|
||||
unsigned char const* getBytes() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_bytes_visitor_const(),*this);
|
||||
}
|
||||
|
||||
unsigned char* getBytes()
|
||||
{
|
||||
return util::apply_visitor(detail::get_bytes_visitor(),*this);
|
||||
}
|
||||
|
||||
std::size_t width() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_width_visitor(),*this);
|
||||
}
|
||||
|
||||
std::size_t height() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_height_visitor(),*this);
|
||||
}
|
||||
|
||||
bool get_premultiplied() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_premultiplied_visitor(),*this);
|
||||
}
|
||||
|
||||
bool painted() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_painted_visitor(),*this);
|
||||
}
|
||||
|
||||
unsigned getSize() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_any_size_visitor(),*this);
|
||||
}
|
||||
|
||||
unsigned getRowSize() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_any_row_size_visitor(),*this);
|
||||
}
|
||||
|
||||
double get_offset() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_offset_visitor(),*this);
|
||||
}
|
||||
|
||||
double get_scaling() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_scaling_visitor(),*this);
|
||||
}
|
||||
|
||||
image_dtype get_dtype() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_dtype_visitor(),*this);
|
||||
}
|
||||
|
||||
void set_offset(double val)
|
||||
{
|
||||
util::apply_visitor(detail::set_offset_visitor(val),*this);
|
||||
}
|
||||
|
||||
void set_scaling(double val)
|
||||
{
|
||||
util::apply_visitor(detail::set_scaling_visitor(val),*this);
|
||||
}
|
||||
};
|
||||
|
||||
inline image_any create_image_any(int width,
|
||||
int height,
|
||||
image_dtype type,
|
||||
bool initialize,
|
||||
bool premultiplied,
|
||||
bool painted)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case image_dtype_gray8:
|
||||
return image_any(std::move(image_gray8(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray8s:
|
||||
return image_any(std::move(image_gray8s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray16:
|
||||
return image_any(std::move(image_gray16(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray16s:
|
||||
return image_any(std::move(image_gray16s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32:
|
||||
return image_any(std::move(image_gray32(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32s:
|
||||
return image_any(std::move(image_gray32s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32f:
|
||||
return image_any(std::move(image_gray32f(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64:
|
||||
return image_any(std::move(image_gray64(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64s:
|
||||
return image_any(std::move(image_gray64s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64f:
|
||||
return image_any(std::move(image_gray64f(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_null:
|
||||
return image_any(std::move(image_null()));
|
||||
case image_dtype_rgba8:
|
||||
case IMAGE_DTYPE_MAX:
|
||||
default:
|
||||
return image_any(std::move(image_rgba8(width, height, initialize, premultiplied, painted)));
|
||||
}
|
||||
}
|
||||
|
||||
} // end mapnik ns
|
||||
|
||||
#endif // MAPNIK_IMAGE_DATA_ANY_HPP
|
||||
#endif // MAPNIK_IMAGE_ANY_HPP
|
||||
|
|
289
include/mapnik/image_impl.hpp
Normal file
289
include/mapnik/image_impl.hpp
Normal file
|
@ -0,0 +1,289 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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_IMAGE_IMPL_HPP
|
||||
#define MAPNIK_IMAGE_IMPL_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/image.hpp>
|
||||
|
||||
// stl
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
image<T,max_size>::image()
|
||||
: dimensions_(0,0),
|
||||
buffer_(0),
|
||||
pData_(nullptr),
|
||||
offset_(0.0),
|
||||
scaling_(1.0),
|
||||
premultiplied_alpha_(false),
|
||||
painted_(false)
|
||||
{}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
image<T,max_size>::image(int width, int height, bool initialize, bool premultiplied, bool painted)
|
||||
: dimensions_(width, height),
|
||||
buffer_(dimensions_.width() * dimensions_.height() * pixel_size),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(0.0),
|
||||
scaling_(1.0),
|
||||
premultiplied_alpha_(premultiplied),
|
||||
painted_(painted)
|
||||
{
|
||||
if (pData_ && initialize)
|
||||
{
|
||||
std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
image<T,max_size>::image(image<T> const& rhs)
|
||||
: dimensions_(rhs.dimensions_),
|
||||
buffer_(rhs.buffer_),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(rhs.offset_),
|
||||
scaling_(rhs.scaling_),
|
||||
premultiplied_alpha_(rhs.premultiplied_alpha_),
|
||||
painted_(rhs.painted_)
|
||||
{}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
image<T,max_size>::image(image<T> && rhs) noexcept
|
||||
: dimensions_(std::move(rhs.dimensions_)),
|
||||
buffer_(std::move(rhs.buffer_)),
|
||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||
offset_(rhs.offset_),
|
||||
scaling_(rhs.scaling_),
|
||||
premultiplied_alpha_(rhs.premultiplied_alpha_),
|
||||
painted_(rhs.painted_)
|
||||
{
|
||||
rhs.dimensions_ = { 0, 0 };
|
||||
rhs.pData_ = nullptr;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
image<T>& image<T,max_size>::operator=(image<T> rhs)
|
||||
{
|
||||
swap(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
void image<T,max_size>::swap(image<T> & rhs)
|
||||
{
|
||||
std::swap(dimensions_, rhs.dimensions_);
|
||||
std::swap(buffer_, rhs.buffer_);
|
||||
std::swap(offset_, rhs.offset_);
|
||||
std::swap(scaling_, rhs.scaling_);
|
||||
std::swap(premultiplied_alpha_, rhs.premultiplied_alpha_);
|
||||
std::swap(painted_, rhs.painted_);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline typename image<T,max_size>::pixel_type& image<T,max_size>::operator() (std::size_t i, std::size_t j)
|
||||
{
|
||||
assert(i < dimensions_.width() && j < dimensions_.height());
|
||||
return pData_[j * dimensions_.width() + i];
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline const typename image<T,max_size>::pixel_type& image<T,max_size>::operator() (std::size_t i, std::size_t j) const
|
||||
{
|
||||
assert(i < dimensions_.width() && j < dimensions_.height());
|
||||
return pData_[j * dimensions_.width() + i];
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline std::size_t image<T,max_size>::width() const
|
||||
{
|
||||
return dimensions_.width();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline std::size_t image<T,max_size>::height() const
|
||||
{
|
||||
return dimensions_.height();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline unsigned image<T,max_size>::getSize() const
|
||||
{
|
||||
return dimensions_.height() * dimensions_.width() * pixel_size;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline unsigned image<T,max_size>::getRowSize() const
|
||||
{
|
||||
return dimensions_.width() * pixel_size;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::set(pixel_type const& t)
|
||||
{
|
||||
std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), t);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline const typename image<T,max_size>::pixel_type* image<T,max_size>::getData() const
|
||||
{
|
||||
return pData_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline typename image<T,max_size>::pixel_type* image<T,max_size>::getData()
|
||||
{
|
||||
return pData_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline const unsigned char* image<T,max_size>::getBytes() const
|
||||
{
|
||||
return buffer_.data();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline unsigned char* image<T,max_size>::getBytes()
|
||||
{
|
||||
return buffer_.data();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline const typename image<T,max_size>::pixel_type* image<T,max_size>::getRow(std::size_t row) const
|
||||
{
|
||||
return pData_ + row * dimensions_.width();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline const typename image<T,max_size>::pixel_type* image<T,max_size>::getRow(std::size_t row, std::size_t x0) const
|
||||
{
|
||||
return pData_ + row * dimensions_.width() + x0;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline typename image<T,max_size>::pixel_type* image<T,max_size>::getRow(std::size_t row)
|
||||
{
|
||||
return pData_ + row * dimensions_.width();
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline typename image<T,max_size>::pixel_type* image<T,max_size>::getRow(std::size_t row, std::size_t x0)
|
||||
{
|
||||
return pData_ + row * dimensions_.width() + x0;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::setRow(std::size_t row, pixel_type const* buf, std::size_t size)
|
||||
{
|
||||
assert(row < dimensions_.height());
|
||||
assert(size <= dimensions_.width());
|
||||
std::copy(buf, buf + size, pData_ + row * dimensions_.width());
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::setRow(std::size_t row, std::size_t x0, std::size_t x1, pixel_type const* buf)
|
||||
{
|
||||
assert(row < dimensions_.height());
|
||||
assert ((x1 - x0) <= dimensions_.width() );
|
||||
std::copy(buf, buf + (x1 - x0), pData_ + row * dimensions_.width() + x0);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline double image<T,max_size>::get_offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::set_offset(double set)
|
||||
{
|
||||
offset_ = set;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline double image<T,max_size>::get_scaling() const
|
||||
{
|
||||
return scaling_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::set_scaling(double set)
|
||||
{
|
||||
if (set != 0.0)
|
||||
{
|
||||
scaling_ = set;
|
||||
return;
|
||||
}
|
||||
std::clog << "Can not set scaling to 0.0, offset not set." << std::endl;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline bool image<T,max_size>::get_premultiplied() const
|
||||
{
|
||||
return premultiplied_alpha_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::set_premultiplied(bool set)
|
||||
{
|
||||
premultiplied_alpha_ = set;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline void image<T,max_size>::painted(bool painted)
|
||||
{
|
||||
painted_ = painted;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline bool image<T,max_size>::painted() const
|
||||
{
|
||||
return painted_;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t max_size>
|
||||
inline image_dtype image<T,max_size>::get_dtype() const
|
||||
{
|
||||
return dtype;
|
||||
}
|
||||
|
||||
/*
|
||||
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>;
|
||||
*/
|
||||
} // end ns
|
||||
|
||||
#endif // MAPNIK_IMAGE_IMPL_HPP
|
|
@ -44,6 +44,7 @@ enum image_dtype : std::uint8_t
|
|||
IMAGE_DTYPE_MAX
|
||||
};
|
||||
|
||||
struct null_t { using type = std::uint8_t; static const image_dtype id = image_dtype_null; };
|
||||
struct rgba8_t { using type = std::uint32_t; static const image_dtype id = image_dtype_rgba8; };
|
||||
struct gray8_t { using type = std::uint8_t; static const image_dtype id = image_dtype_gray8; };
|
||||
struct gray8s_t { using type = std::int8_t; static const image_dtype id = image_dtype_gray8s; };
|
||||
|
|
|
@ -174,6 +174,9 @@ source = Split(
|
|||
parse_path.cpp
|
||||
image_reader.cpp
|
||||
cairo_io.cpp
|
||||
image.cpp
|
||||
image_any.cpp
|
||||
image_null.cpp
|
||||
image_util.cpp
|
||||
image_util_jpeg.cpp
|
||||
image_util_png.cpp
|
||||
|
|
45
src/image.cpp
Normal file
45
src/image.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/image.hpp>
|
||||
#include <mapnik/image_impl.hpp>
|
||||
#include <mapnik/pixel_types.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
template class MAPNIK_DECL image<null_t>;
|
||||
template class MAPNIK_DECL image<rgba8_t>;
|
||||
template class MAPNIK_DECL image<gray8_t>;
|
||||
template class MAPNIK_DECL image<gray8s_t>;
|
||||
template class MAPNIK_DECL image<gray16_t>;
|
||||
template class MAPNIK_DECL image<gray16s_t>;
|
||||
template class MAPNIK_DECL image<gray32_t>;
|
||||
template class MAPNIK_DECL image<gray32s_t>;
|
||||
template class MAPNIK_DECL image<gray32f_t>;
|
||||
template class MAPNIK_DECL image<gray64_t>;
|
||||
template class MAPNIK_DECL image<gray64s_t>;
|
||||
template class MAPNIK_DECL image<gray64f_t>;
|
||||
|
||||
} // end ns
|
297
src/image_any.cpp
Normal file
297
src/image_any.cpp
Normal file
|
@ -0,0 +1,297 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/image_any.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct get_bytes_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned char* operator()(T & data)
|
||||
{
|
||||
return data.getBytes();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_dtype_visitor
|
||||
{
|
||||
template <typename T>
|
||||
image_dtype operator()(T & data)
|
||||
{
|
||||
return data.get_dtype();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_bytes_visitor_const
|
||||
{
|
||||
template <typename T>
|
||||
unsigned char const* operator()(T const& data) const
|
||||
{
|
||||
return data.getBytes();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_width_visitor
|
||||
{
|
||||
template <typename T>
|
||||
std::size_t operator()(T const& data) const
|
||||
{
|
||||
return data.width();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_height_visitor
|
||||
{
|
||||
template <typename T>
|
||||
std::size_t operator()(T const& data) const
|
||||
{
|
||||
return data.height();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_premultiplied_visitor
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(T const& data) const
|
||||
{
|
||||
return data.get_premultiplied();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_painted_visitor
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(T const& data) const
|
||||
{
|
||||
return data.painted();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_any_size_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned operator()(T const& data) const
|
||||
{
|
||||
return data.getSize();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_any_row_size_visitor
|
||||
{
|
||||
template <typename T>
|
||||
unsigned operator()(T const& data) const
|
||||
{
|
||||
return data.getRowSize();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_offset_visitor
|
||||
{
|
||||
template <typename T>
|
||||
double operator() (T const& data) const
|
||||
{
|
||||
return data.get_offset();
|
||||
}
|
||||
};
|
||||
|
||||
struct get_scaling_visitor
|
||||
{
|
||||
template <typename T>
|
||||
double operator() (T const& data) const
|
||||
{
|
||||
return data.get_scaling();
|
||||
}
|
||||
};
|
||||
|
||||
struct set_offset_visitor
|
||||
{
|
||||
set_offset_visitor(double val)
|
||||
: val_(val) {}
|
||||
template <typename T>
|
||||
void operator() (T & data)
|
||||
{
|
||||
data.set_offset(val_);
|
||||
}
|
||||
private:
|
||||
double val_;
|
||||
};
|
||||
|
||||
struct set_scaling_visitor
|
||||
{
|
||||
set_scaling_visitor(double val)
|
||||
: val_(val) {}
|
||||
template <typename T>
|
||||
void operator() (T & data)
|
||||
{
|
||||
data.set_scaling(val_);
|
||||
}
|
||||
private:
|
||||
double val_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
image_any::image_any(int width,
|
||||
int height,
|
||||
image_dtype type,
|
||||
bool initialize,
|
||||
bool premultiplied,
|
||||
bool painted)
|
||||
: image_base(std::move(create_image_any(width, height, type, initialize, premultiplied, painted))) {}
|
||||
|
||||
template <typename T>
|
||||
image_any::image_any(T && data) noexcept
|
||||
: image_base(std::move(data)) {}
|
||||
|
||||
template image_any::image_any(image_null && data) noexcept;
|
||||
template image_any::image_any(image_rgba8 && data) noexcept;
|
||||
template image_any::image_any(image_gray8 && data) noexcept;
|
||||
template image_any::image_any(image_gray8s && data) noexcept;
|
||||
template image_any::image_any(image_gray16 && data) noexcept;
|
||||
template image_any::image_any(image_gray16s && data) noexcept;
|
||||
template image_any::image_any(image_gray32 && data) noexcept;
|
||||
template image_any::image_any(image_gray32s && data) noexcept;
|
||||
template image_any::image_any(image_gray32f && data) noexcept;
|
||||
template image_any::image_any(image_gray64 && data) noexcept;
|
||||
template image_any::image_any(image_gray64s && data) noexcept;
|
||||
template image_any::image_any(image_gray64f && data) noexcept;
|
||||
template image_any::image_any(image_null const& data) noexcept;
|
||||
template image_any::image_any(image_rgba8 const& data) noexcept;
|
||||
template image_any::image_any(image_gray8 const& data) noexcept;
|
||||
template image_any::image_any(image_gray8s const& data) noexcept;
|
||||
template image_any::image_any(image_gray16 const& data) noexcept;
|
||||
template image_any::image_any(image_gray16s const& data) noexcept;
|
||||
template image_any::image_any(image_gray32 const& data) noexcept;
|
||||
template image_any::image_any(image_gray32s const& data) noexcept;
|
||||
template image_any::image_any(image_gray32f const& data) noexcept;
|
||||
template image_any::image_any(image_gray64 const& data) noexcept;
|
||||
template image_any::image_any(image_gray64s const& data) noexcept;
|
||||
template image_any::image_any(image_gray64f const& data) noexcept;
|
||||
|
||||
unsigned char const* image_any::getBytes() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_bytes_visitor_const(),*this);
|
||||
}
|
||||
|
||||
unsigned char* image_any::getBytes()
|
||||
{
|
||||
return util::apply_visitor(detail::get_bytes_visitor(),*this);
|
||||
}
|
||||
|
||||
std::size_t image_any::width() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_width_visitor(),*this);
|
||||
}
|
||||
|
||||
std::size_t image_any::height() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_height_visitor(),*this);
|
||||
}
|
||||
|
||||
bool image_any::get_premultiplied() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_premultiplied_visitor(),*this);
|
||||
}
|
||||
|
||||
bool image_any::painted() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_painted_visitor(),*this);
|
||||
}
|
||||
|
||||
unsigned image_any::getSize() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_any_size_visitor(),*this);
|
||||
}
|
||||
|
||||
unsigned image_any::getRowSize() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_any_row_size_visitor(),*this);
|
||||
}
|
||||
|
||||
double image_any::get_offset() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_offset_visitor(),*this);
|
||||
}
|
||||
|
||||
double image_any::get_scaling() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_scaling_visitor(),*this);
|
||||
}
|
||||
|
||||
image_dtype image_any::get_dtype() const
|
||||
{
|
||||
return util::apply_visitor(detail::get_dtype_visitor(),*this);
|
||||
}
|
||||
|
||||
void image_any::set_offset(double val)
|
||||
{
|
||||
util::apply_visitor(detail::set_offset_visitor(val),*this);
|
||||
}
|
||||
|
||||
void image_any::set_scaling(double val)
|
||||
{
|
||||
util::apply_visitor(detail::set_scaling_visitor(val),*this);
|
||||
}
|
||||
|
||||
|
||||
image_any create_image_any(int width,
|
||||
int height,
|
||||
image_dtype type,
|
||||
bool initialize,
|
||||
bool premultiplied,
|
||||
bool painted)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case image_dtype_gray8:
|
||||
return image_any(std::move(image_gray8(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray8s:
|
||||
return image_any(std::move(image_gray8s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray16:
|
||||
return image_any(std::move(image_gray16(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray16s:
|
||||
return image_any(std::move(image_gray16s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32:
|
||||
return image_any(std::move(image_gray32(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32s:
|
||||
return image_any(std::move(image_gray32s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray32f:
|
||||
return image_any(std::move(image_gray32f(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64:
|
||||
return image_any(std::move(image_gray64(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64s:
|
||||
return image_any(std::move(image_gray64s(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_gray64f:
|
||||
return image_any(std::move(image_gray64f(width, height, initialize, premultiplied, painted)));
|
||||
case image_dtype_null:
|
||||
return image_any(std::move(image_null()));
|
||||
case image_dtype_rgba8:
|
||||
case IMAGE_DTYPE_MAX:
|
||||
default:
|
||||
return image_any(std::move(image_rgba8(width, height, initialize, premultiplied, painted)));
|
||||
}
|
||||
}
|
||||
|
||||
} // end mapnik ns
|
68
src/image_null.cpp
Normal file
68
src/image_null.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/image.hpp>
|
||||
#include <mapnik/pixel_types.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
template <>
|
||||
class image<null_t>
|
||||
{
|
||||
public:
|
||||
using pixel_type = typename null_t::type;
|
||||
static const image_dtype dtype = null_t::id;
|
||||
private:
|
||||
public:
|
||||
image() {}
|
||||
image(int width,
|
||||
int height,
|
||||
bool initialize = true,
|
||||
bool premultiplied = false,
|
||||
bool painted = false) {}
|
||||
image(image<null_t> const& rhs) {}
|
||||
image(image<null_t> && rhs) noexcept {}
|
||||
|
||||
void swap(image<null_t> & rhs) {}
|
||||
std::size_t width() const { return 0; }
|
||||
std::size_t height() const { return 0; }
|
||||
unsigned getSize() const { return 0; }
|
||||
unsigned getRowSize() const { return 0; }
|
||||
void set(pixel_type const& t) { throw std::runtime_error("Can not set values for null image"); }
|
||||
const unsigned char* getBytes() const { return nullptr; }
|
||||
unsigned char* getBytes() {return nullptr; }
|
||||
double get_offset() const { return 0.0; }
|
||||
void set_offset(double set) {}
|
||||
double get_scaling() const { return 1.0; }
|
||||
void set_scaling(double set) {}
|
||||
bool get_premultiplied() const { return false; }
|
||||
void set_premultiplied(bool set) {}
|
||||
void painted(bool painted) {}
|
||||
bool painted() const { return false; }
|
||||
image_dtype get_dtype() const { return dtype; }
|
||||
};
|
||||
|
||||
} // end ns mapnik
|
Loading…
Add table
Reference in a new issue