13#include <boost/operators.hpp>
14#include <boost/utility.hpp>
25 using Ptr = std::shared_ptr<BitmapSurface>;
29 std::shared_ptr<unsigned char>
const data;
32 static Ptr create(
int width,
int height, cairo_format_t format);
33 static Ptr create(
int width,
int height, cairo_format_t format,
int stride, std::shared_ptr<unsigned char>
const&
data);
41 cairo_surface_t*
get();
45 BitmapSurface(
int width,
int height, cairo_format_t format,
int stride, std::shared_ptr<unsigned char>
const&
data);
60 template <
typename ConstBase>
61 class SampleIterator :
public boost::addable2<SampleIterator<ConstBase>, unsigned int>
64 using Base = std::remove_const_t<ConstBase>;
66 static const int bitsPerBase{8 *
sizeof(ConstBase) /
sizeof(
byte)};
77 static Base mask(
int bps) {
return (((ConstBase(1) << (
bps - 1)) - 1) << 1) | 1; }
const uint8_t value
Definition blob-tests.cc:114
Definition bitmap-helpers.hh:23
BitmapSurface(const BitmapSurface &)=delete
std::shared_ptr< unsigned char > const data
Definition bitmap-helpers.hh:29
std::shared_ptr< BitmapSurface > Ptr
Definition bitmap-helpers.hh:25
cairo_surface_t * get()
Definition bitmap-helpers.cc:26
cairo_surface_t *const surface
Definition bitmap-helpers.hh:28
BitmapSurface(BitmapSurface &&)=delete
static Ptr create(int width, int height, cairo_format_t format)
Definition bitmap-helpers.cc:13
BitmapSurface & operator=(const BitmapSurface &)=delete
~BitmapSurface()
Definition bitmap-helpers.cc:24
BitmapSurface & operator=(BitmapSurface &&)=delete
Definition bitmap-helpers.hh:62
Base get()
Definition bitmap-helpers.hh:105
bool operator!=(const SampleIterator< ConstBase > &other) const
Definition bitmap-helpers.hh:160
static const int bitsPerBase
Definition bitmap-helpers.hh:66
const int bps
Definition bitmap-helpers.hh:68
void set(ConstBase value)
Definition bitmap-helpers.hh:108
int currentOffset
Definition bitmap-helpers.hh:74
const int pixelOffset
Definition bitmap-helpers.hh:70
SampleIterator operator++(int)
Definition bitmap-helpers.hh:127
SampleIterator & operator++()
Definition bitmap-helpers.hh:114
static Base mask(int bps)
Definition bitmap-helpers.hh:77
const ConstBase pixelMask
Definition bitmap-helpers.hh:71
SampleIterator(div_t d, ConstBase *base, int bps_)
Definition bitmap-helpers.hh:79
SampleIterator & operator+=(unsigned int x)
Definition bitmap-helpers.hh:142
Base operator*()
Definition bitmap-helpers.hh:153
SampleIterator(ConstBase *base, int offset=0, int bps_=1)
Definition bitmap-helpers.hh:99
ConstBase * currentBase
Definition bitmap-helpers.hh:73
const int samplesPerBase
Definition bitmap-helpers.hh:69
std::remove_const_t< ConstBase > Base
Definition bitmap-helpers.hh:64
bool operator==(const SampleIterator< ConstBase > &other) const
Definition bitmap-helpers.hh:155
Definition bitmap-helpers.hh:21
auto mask
Definition ruler-tests.cc:21
SampleIterator< const uint8_t > result
Definition sampleiterator-tests.cc:94