6#include "TTauri/Foundation/required.hpp"
7#include "TTauri/Foundation/iaarect.hpp"
29 T
const *
data() const noexcept {
62 tt_assert(columnNr >= 0 && columnNr <
width);
73 tt_assert(columnNr >= 0 && columnNr <
width);
118 tt_assert(
width > 0);
121 tt_assert(
width == 0);
136 tt_assert(
width > 0);
139 tt_assert(
width == 0);
171 gsl_suppress2(r.11,i.11)
187 ttlet src_row = (*this)[y];
190 dst_row[x] = src_row[x];
201 tt_assume(
this != &other);
202 other.selfAllocated =
false;
205 operator bool() const noexcept {
213 gsl_suppress2(r.11,i.11)
224 other.selfAllocated =
false;
228 ivec extent() const noexcept {
236 PixelMap<T> submap(iaarect rect)
const noexcept {
240 (rect.width() >= 0) &&
244 (rect.x2() <=
width) &&
248 ttlet offset = rect.y1() *
stride + rect.x1();
250 return {
pixels + offset, rect.width(), rect.height(),
stride };
260 PixelMap<T> submap(ssize_t x, ssize_t y, ssize_t _width, ssize_t _height)
const noexcept {
261 return submap(iaarect{x, y, _width, _height});
264 PixelRow<T>
const operator[](ssize_t rowNr)
const noexcept {
268 PixelRow<T> operator[](ssize_t rowNr)
noexcept {
272 PixelRow<T>
const at(ssize_t rowNr)
const noexcept {
273 tt_assert(rowNr <
height);
274 return (*
this)[rowNr];
277 PixelRow<T> at(ssize_t rowNr)
noexcept {
278 tt_assert(rowNr <
height);
279 return (*
this)[rowNr];
284void copy(PixelMap<T>
const &src, PixelMap<T> &dst)
noexcept {
285 ssize_t width =
std::min(src.width, dst.width);
286 ssize_t height =
std::min(src.height, dst.height);
288 for (ssize_t y = 0; y != height; ++y) {
289 ttlet src_row = src[y];
290 auto dst_row = dst[y];
291 for (ssize_t x = 0; x != width; ++x) {
292 dst_row[x] = src_row[x];
297template<
int KERNEL_SIZE,
typename KERNEL>
298void horizontalFilterRow(PixelRow<uint8_t> row, KERNEL kernel)
noexcept;
300template<
int KERNEL_SIZE,
typename T,
typename KERNEL>
301void horizontalFilter(PixelMap<T>& pixels, KERNEL kernel)
noexcept;
306void fill(PixelMap<T> &dst)
noexcept;
311void fill(PixelMap<T> &dst, T color)
noexcept;
316void rotate90(PixelMap<T> &dst, PixelMap<T>
const &src)
noexcept;
321void rotate270(PixelMap<T> &dst, PixelMap<T>
const &src)
noexcept;
325void mergeMaximum(PixelMap<uint8_t> &dst, PixelMap<uint8_t>
const &src)
noexcept;
333inline void makeTransparentBorder(PixelMap<T> & pixelMap)
noexcept;
A 4D vector.
Definition ivec.hpp:37
A 2D canvas of pixels.
Definition PixelMap.hpp:83
PixelMap(PixelMap const &other)=delete
Disallowing copying so that life-time of selfAllocated pixels is easy to understand.
PixelMap(T *pixels, ivec extent) noexcept
Construct an pixel-map from memory received from an API.
Definition PixelMap.hpp:162
gsl_suppress(r.11) PixelMap(ssize_t width
Construct an pixel-map.
ssize_t height
Number of vertical pixels.
Definition PixelMap.hpp:94
ssize_t width
Number of horizontal pixels.
Definition PixelMap.hpp:90
ssize_t stride
Number of pixel element until the next row.
Definition PixelMap.hpp:99
bool selfAllocated
True if the memory was allocated by this class, false if the canvas was received from another API.
Definition PixelMap.hpp:103
PixelMap(T *pixels, ssize_t width, ssize_t height, ssize_t stride) noexcept
Construct an pixel-map from memory received from an API.
Definition PixelMap.hpp:115
T * pixels
Pointer to a 2D canvas of pixels.
Definition PixelMap.hpp:86
PixelMap() noexcept
Construct an empty pixel-map.
Definition PixelMap.hpp:107
PixelMap & operator=(PixelMap const &other)=delete
Disallowing copying so that life-time of selfAllocated pixels is easy to understand.
PixelMap(ivec extent) noexcept
Construct an pixel-map.
Definition PixelMap.hpp:149
PixelMap(T *pixels, ssize_t width, ssize_t height) noexcept
Construct an pixel-map from memory received from an API.
Definition PixelMap.hpp:156
PixelMap(T *pixels, ivec extent, ssize_t stride) noexcept
Construct an pixel-map from memory received from an API.
Definition PixelMap.hpp:169
A row of pixels.
Definition PixelMap.hpp:18
T const * data() const noexcept
Get a pointer to the pixel data.
Definition PixelMap.hpp:29
T const & at(ssize_t columnNr) const noexcept
Get a access to a pixel in the row.
Definition PixelMap.hpp:61
ssize_t width
Number of pixels in the row.
Definition PixelMap.hpp:25
T * pixels
Pointer to an array of pixels.
Definition PixelMap.hpp:21
T * data() noexcept
Get a pointer to the pixel data.
Definition PixelMap.hpp:35
T const & operator[](ssize_t columnNr) const noexcept
Get a access to a pixel in the row.
Definition PixelMap.hpp:43
T & at(ssize_t columnNr) noexcept
Get a access to a pixel in the row.
Definition PixelMap.hpp:72
T & operator[](ssize_t columnNr) noexcept
Get a access to a pixel in the row.
Definition PixelMap.hpp:51