/usr/include/mapnik/image.hpp is in libmapnik-dev 3.0.9+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | /*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 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_HPP
#define MAPNIK_IMAGE_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/pixel_types.hpp>
namespace mapnik {
namespace detail {
struct MAPNIK_DECL buffer
{
explicit buffer(std::size_t size);
explicit buffer(unsigned char* data, std::size_t size);
buffer(buffer && rhs) noexcept;
buffer(buffer const& rhs);
~buffer();
buffer& operator=(buffer rhs);
inline bool operator!() const {return (data_ == nullptr)? true : false;}
inline unsigned char* data() {return data_;}
inline unsigned char const* data() const {return data_;}
inline std::size_t size() const {return size_;}
private:
void swap(buffer & rhs);
std::size_t size_;
unsigned char* data_;
bool owns_;
};
template <std::size_t max_size>
struct image_dimensions
{
image_dimensions(int width, int height);
image_dimensions(image_dimensions const& other) = default;
image_dimensions(image_dimensions && other) = default;
image_dimensions& operator= (image_dimensions rhs);
std::size_t width() const;
std::size_t height() const;
private:
std::size_t width_;
std::size_t height_;
};
} // end ns detail
template <typename T>
class image
{
public:
using pixel = T;
using pixel_type = typename T::type;
using iterator = pixel_type*;
using const_iterator = pixel_type const*;
static constexpr image_dtype dtype = T::id;
static constexpr std::size_t pixel_size = sizeof(pixel_type);
private:
detail::image_dimensions<65535> dimensions_;
detail::buffer buffer_;
pixel_type *pData_;
double offset_;
double scaling_;
bool premultiplied_alpha_;
bool painted_;
public:
image();
image(int width,
int height,
bool initialize = true,
bool premultiplied = false,
bool painted = false);
image(int width,
int height,
unsigned char* data,
bool premultiplied = false,
bool painted = false);
image(image<T> const& rhs);
image(image<T> && rhs) noexcept;
image<T>& operator=(image<T> rhs);
bool operator==(image<T> const& rhs) const;
bool operator<(image<T> const& rhs) const;
void swap(image<T> & rhs);
pixel_type& operator() (std::size_t i, std::size_t j);
pixel_type const& operator() (std::size_t i, std::size_t j) const;
std::size_t width() const;
std::size_t height() const;
std::size_t size() const;
std::size_t row_size() const;
void set(pixel_type const& t);
pixel_type const* data() const;
pixel_type* data();
// simple iterator inteface
const_iterator begin() const;
const_iterator end() const;
iterator begin();
iterator end();
//
unsigned char const* bytes() const;
unsigned char* bytes();
pixel_type const* get_row(std::size_t row) const;
pixel_type const* get_row(std::size_t row, std::size_t x0) const;
pixel_type* get_row(std::size_t row);
pixel_type* get_row(std::size_t row, std::size_t x0);
void set_row(std::size_t row, pixel_type const* buf, std::size_t size);
void set_row(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>;
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 mapnik
#endif // MAPNIK_IMAGE_HPP
|