31 #ifndef PNGPP_PIXEL_BUFFER_HPP_INCLUDED 32 #define PNGPP_PIXEL_BUFFER_HPP_INCLUDED 58 template<
typename pixel,
112 for (
typename row_vec::iterator r =
m_rows.begin();
195 template<
typename pixel >
212 template<
typename pixel >
230 template<
class pixel,
typename reference >
242 m_shift(get_shift(index))
246 operator pixel()
const 248 return pixel((m_ref >> m_shift) & pixel::get_bit_mask());
260 int const bits = pixel::get_bit_depth();
261 return (8 - bits) - (index % get_pixels_per_byte()) * bits;
266 return 8 / pixel::get_bit_depth();
273 template<
class pixel >
284 template<
class pixel >
292 : basic_proxy(ref, index)
297 : basic_proxy(other.m_ref)
304 return *
this =
static_cast< pixel
>(other);
307 template<
typename reference >
311 return *
this =
static_cast< pixel
>(other);
316 this->m_ref = (this->m_ref
317 & ~(pixel::get_bit_mask() << this->m_shift))
318 | (p << this->m_shift);
332 template<
class pixel >
354 m_vec.resize(size / get_pixels_per_byte()
355 + (size % get_pixels_per_byte() ? 1 : 0));
373 const_pixel_proxy
at(
size_t index)
const 375 return const_pixel_proxy(m_vec.at(index / get_pixels_per_byte()),
383 pixel_proxy
at(
size_t index)
385 return pixel_proxy(m_vec.at(index / get_pixels_per_byte()),
395 return const_pixel_proxy(m_vec[index / get_pixels_per_byte()],
405 return pixel_proxy(m_vec[index / get_pixels_per_byte()],
414 assert(m_vec.size());
419 static size_t get_pixels_per_byte()
421 return 8 / pixel::get_bit_depth();
424 std::vector< byte > m_vec;
432 template<
typename pixel >
452 packed_pixel_row< packed_gray_pixel
465 pixel_row_type >(width, height)
477 packed_pixel_row< packed_index_pixel
490 pixel_row_type >(width, height)
497 #endif // PNGPP_PIXEL_BUFFER_HPP_INCLUDED row_const_access operator[](size_t index) const
The non-checking version of get_row() method.
Definition: pixel_buffer.hpp:155
const_pixel_proxy at(size_t index) const
Returns an immutable proxy the to the pixel at index.
Definition: pixel_buffer.hpp:373
The pixel row traits class template. Provides a common way to get starting address of the row for pac...
Definition: pixel_buffer.hpp:53
basic_pixel_buffer()
Constructs an empty 0x0 pixel buffer object.
Definition: pixel_buffer.hpp:75
detail::const_packed_pixel_proxy< pixel > const_pixel_proxy
The immutable packed pixel proxy type.
Definition: pixel_buffer.hpp:362
packed_pixel_proxy & operator=(pixel p)
Definition: pixel_buffer.hpp:314
row_vec m_rows
Definition: pixel_buffer.hpp:189
void set_pixel(size_t x, size_t y, pixel p)
Replaces a pixel at (x,y) position.
Definition: pixel_buffer.hpp:180
detail::packed_pixel_proxy< pixel > pixel_proxy
The mutable packed pixel proxy type.
Definition: pixel_buffer.hpp:367
basic_pixel_buffer(uint_32 width, uint_32 height)
Constructs an empty pixel buffer object.
Definition: pixel_buffer.hpp:84
pixel_proxy operator[](size_t index)
Returns n mutable proxy the to the pixel at index. The non-checking version.
Definition: pixel_buffer.hpp:403
static byte * get_data(packed_pixel_row< pixel > &row)
Returns the starting address of the row.
Definition: pixel_buffer.hpp:439
Definition: pixel_buffer.hpp:274
size_t size() const
Definition: pixel_buffer.hpp:344
reference m_ref
Definition: pixel_buffer.hpp:269
uint_32 get_height() const
Definition: pixel_buffer.hpp:96
row_type const & row_const_access
Definition: pixel_buffer.hpp:69
row_const_access get_row(size_t index) const
Returns a const reference to the row of image data at specified index.
Definition: pixel_buffer.hpp:139
packed_pixel_proxy & operator=(basic_packed_pixel_proxy< pixel, reference > const &other)
Definition: pixel_buffer.hpp:309
row_access operator[](size_t index)
The non-checking version of get_row() method.
Definition: pixel_buffer.hpp:147
Definition: pixel_buffer.hpp:213
byte * get_data()
Returns the starting address of the row.
Definition: pixel_buffer.hpp:412
uint_32 get_width() const
Definition: pixel_buffer.hpp:91
std::vector< row_type > row_vec
Definition: pixel_buffer.hpp:188
packed_pixel_row(size_t size=0)
Constructs a pixel row object for size packed pixels.
Definition: pixel_buffer.hpp:339
size_t m_shift
Definition: pixel_buffer.hpp:270
basic_packed_pixel_proxy(reference ref, size_t index)
Definition: pixel_buffer.hpp:240
uint_32 m_height
Definition: pixel_buffer.hpp:187
pixel_buffer(uint_32 width, uint_32 height)
Definition: pixel_buffer.hpp:221
const_packed_pixel_proxy(byte const &ref, size_t index)
Definition: pixel_buffer.hpp:278
row_access get_row(size_t index)
Returns a reference to the row of image data at specified index.
Definition: pixel_buffer.hpp:128
pixel get_pixel(size_t x, size_t y) const
Returns a pixel at (x,y) position.
Definition: pixel_buffer.hpp:172
packed_pixel_proxy & operator=(packed_pixel_proxy const &other)
Definition: pixel_buffer.hpp:302
pixel_buffer()
Definition: pixel_buffer.hpp:459
png_uint_32 uint_32
Definition: types.hpp:41
static size_t get_shift(size_t index)
Definition: pixel_buffer.hpp:258
png_byte byte
Definition: types.hpp:39
row_type & row_access
Definition: pixel_buffer.hpp:68
Definition: pixel_buffer.hpp:231
The basic class template to represent image pixel data.
Definition: pixel_buffer.hpp:61
const_pixel_proxy operator[](size_t index) const
Returns an immutable proxy the to the pixel at index. The non-checking version.
Definition: pixel_buffer.hpp:393
row row_type
A row of pixel data.
Definition: pixel_buffer.hpp:67
pixel_proxy at(size_t index)
Returns a mutable proxy the to the pixel at index.
Definition: pixel_buffer.hpp:383
void resize(uint_32 width, uint_32 height)
Resizes the pixel buffer.
Definition: pixel_buffer.hpp:107
packed_pixel_row< pixel_type > pixel_row_type
Definition: pixel_buffer.hpp:482
static pixel * get_data(std::vector< pixel > &vec)
Returns the starting address of the row.
Definition: pixel_buffer.hpp:202
The packed pixel row class template.
Definition: pixel_buffer.hpp:333
Definition: pixel_buffer.hpp:285
uint_32 m_width
Definition: pixel_buffer.hpp:186
pixel_buffer()
Definition: pixel_buffer.hpp:217
The packed indexed pixel class template. The available specializations are for 1-, 2- and 4-bit pixels.
Definition: index_pixel.hpp:66
packed_index_pixel< bits > pixel_type
Definition: pixel_buffer.hpp:481
packed_pixel_row< pixel_type > pixel_row_type
Definition: pixel_buffer.hpp:457
pixel_buffer(uint_32 width, uint_32 height)
Definition: pixel_buffer.hpp:463
basic_packed_pixel_proxy< pixel, byte &> basic_proxy
Definition: pixel_buffer.hpp:289
packed_gray_pixel< bits > pixel_type
Definition: pixel_buffer.hpp:456
traits row_traits
Definition: pixel_buffer.hpp:70
void resize(size_t size)
Resizes the pixel row to hold up to size packed pixels.
Definition: pixel_buffer.hpp:352
static size_t get_pixels_per_byte()
Definition: pixel_buffer.hpp:264
packed_pixel_proxy(packed_pixel_proxy const &other)
Definition: pixel_buffer.hpp:296
The packed gray pixel class template. The available specializations are for 1-, 2- and 4-bit pixels...
Definition: gray_pixel.hpp:56
pixel_buffer()
Definition: pixel_buffer.hpp:484
basic_packed_pixel_proxy(reference ref)
Definition: pixel_buffer.hpp:234
void put_row(size_t index, row_type const &r)
Replaces the row at specified index.
Definition: pixel_buffer.hpp:163
pixel_buffer(uint_32 width, uint_32 height)
Definition: pixel_buffer.hpp:488
packed_pixel_proxy(byte &ref, size_t index)
Definition: pixel_buffer.hpp:291