31 #ifndef PNGPP_PIXEL_BUFFER_HPP_INCLUDED 32 #define PNGPP_PIXEL_BUFFER_HPP_INCLUDED 58 template<
typename pixel,
110 for (
typename row_vec::iterator r =
m_rows.begin();
193 template<
typename pixel >
210 template<
typename pixel >
228 template<
class pixel,
typename reference >
240 m_shift(get_shift(index))
244 operator pixel()
const 246 return pixel((m_ref >> m_shift) & pixel::get_bit_mask());
258 size_t const bits = pixel::get_bit_depth();
259 return (8 - bits) - (index % get_pixels_per_byte()) * bits;
264 return 8 / pixel::get_bit_depth();
271 template<
class pixel >
282 template<
class pixel >
290 : basic_proxy(ref, index)
295 : basic_proxy(other.m_ref)
302 return *
this =
static_cast< pixel
>(other);
305 template<
typename reference >
309 return *
this =
static_cast< pixel
>(other);
314 this->m_ref = (this->m_ref
315 & ~(pixel::get_bit_mask() << this->m_shift))
316 | (p << this->m_shift);
330 template<
class pixel >
352 m_vec.resize(size / get_pixels_per_byte()
353 + (size % get_pixels_per_byte() ? 1 : 0));
371 const_pixel_proxy
at(
size_t index)
const 373 return const_pixel_proxy(m_vec.at(index / get_pixels_per_byte()),
381 pixel_proxy
at(
size_t index)
383 return pixel_proxy(m_vec.at(index / get_pixels_per_byte()),
393 return const_pixel_proxy(m_vec[index / get_pixels_per_byte()],
403 return pixel_proxy(m_vec[index / get_pixels_per_byte()],
412 assert(m_vec.size());
417 static size_t get_pixels_per_byte()
419 return 8 / pixel::get_bit_depth();
422 std::vector< byte > m_vec;
430 template<
typename pixel >
447 template<
size_t bits >
450 packed_pixel_row< packed_gray_pixel
463 pixel_row_type >(width, height)
472 template<
size_t bits >
475 packed_pixel_row< packed_index_pixel
488 pixel_row_type >(width, height)
495 #endif // PNGPP_PIXEL_BUFFER_HPP_INCLUDED
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:73
detail::const_packed_pixel_proxy< pixel > const_pixel_proxy
The immutable packed pixel proxy type.
Definition: pixel_buffer.hpp:360
packed_pixel_proxy & operator=(pixel p)
Definition: pixel_buffer.hpp:312
row_vec m_rows
Definition: pixel_buffer.hpp:187
void set_pixel(size_t x, size_t y, pixel p)
Replaces a pixel at (x,y) position.
Definition: pixel_buffer.hpp:178
detail::packed_pixel_proxy< pixel > pixel_proxy
The mutable packed pixel proxy type.
Definition: pixel_buffer.hpp:365
size_t size() const
Definition: pixel_buffer.hpp:342
pixel_proxy operator[](size_t index)
Returns n mutable proxy the to the pixel at index. The non-checking version.
Definition: pixel_buffer.hpp:401
static byte * get_data(packed_pixel_row< pixel > &row)
Returns the starting address of the row.
Definition: pixel_buffer.hpp:437
const_pixel_proxy at(size_t index) const
Returns an immutable proxy the to the pixel at index.
Definition: pixel_buffer.hpp:371
Definition: pixel_buffer.hpp:272
reference m_ref
Definition: pixel_buffer.hpp:267
packed_pixel_proxy & operator=(basic_packed_pixel_proxy< pixel, reference > const &other)
Definition: pixel_buffer.hpp:307
Definition: pixel_buffer.hpp:211
byte * get_data()
Returns the starting address of the row.
Definition: pixel_buffer.hpp:410
size_t get_height() const
Definition: pixel_buffer.hpp:94
size_t get_width() const
Definition: pixel_buffer.hpp:89
pixel_buffer(size_t width, size_t height)
Definition: pixel_buffer.hpp:219
std::vector< row_type > row_vec
Definition: pixel_buffer.hpp:186
size_t m_width
Definition: pixel_buffer.hpp:184
row_type const & operator[](size_t index) const
The non-checking version of get_row() method.
Definition: pixel_buffer.hpp:153
row_type const & get_row(size_t index) const
Returns a const reference to the row of image data at specified index.
Definition: pixel_buffer.hpp:137
packed_pixel_row(size_t size=0)
Constructs a pixel row object for size packed pixels.
Definition: pixel_buffer.hpp:337
size_t m_shift
Definition: pixel_buffer.hpp:268
basic_packed_pixel_proxy(reference ref, size_t index)
Definition: pixel_buffer.hpp:238
row_type & get_row(size_t index)
Returns a reference to the row of image data at specified index.
Definition: pixel_buffer.hpp:126
const_packed_pixel_proxy(byte const &ref, size_t index)
Definition: pixel_buffer.hpp:276
packed_pixel_proxy & operator=(packed_pixel_proxy const &other)
Definition: pixel_buffer.hpp:300
pixel_buffer()
Definition: pixel_buffer.hpp:457
static size_t get_shift(size_t index)
Definition: pixel_buffer.hpp:256
png_byte byte
Definition: types.hpp:39
Definition: pixel_buffer.hpp:229
pixel_buffer(size_t width, size_t height)
Definition: pixel_buffer.hpp:461
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:391
The basic class template to represent image pixel data.
Definition: pixel_buffer.hpp:61
row row_type
A row of pixel data.
Definition: pixel_buffer.hpp:67
pixel_buffer(size_t width, size_t height)
Definition: pixel_buffer.hpp:486
pixel_proxy at(size_t index)
Returns a mutable proxy the to the pixel at index.
Definition: pixel_buffer.hpp:381
pixel get_pixel(size_t x, size_t y) const
Returns a pixel at (x,y) position.
Definition: pixel_buffer.hpp:170
row_type & operator[](size_t index)
The non-checking version of get_row() method.
Definition: pixel_buffer.hpp:145
void resize(size_t width, size_t height)
Resizes the pixel buffer.
Definition: pixel_buffer.hpp:105
packed_pixel_row< pixel_type > pixel_row_type
Definition: pixel_buffer.hpp:480
static pixel * get_data(std::vector< pixel > &vec)
Returns the starting address of the row.
Definition: pixel_buffer.hpp:200
The packed pixel row class template.
Definition: pixel_buffer.hpp:331
Definition: pixel_buffer.hpp:283
pixel_buffer()
Definition: pixel_buffer.hpp:215
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:479
packed_pixel_row< pixel_type > pixel_row_type
Definition: pixel_buffer.hpp:455
basic_packed_pixel_proxy< pixel, byte & > basic_proxy
Definition: pixel_buffer.hpp:287
packed_gray_pixel< bits > pixel_type
Definition: pixel_buffer.hpp:454
basic_pixel_buffer(size_t width, size_t height)
Constructs an empty pixel buffer object.
Definition: pixel_buffer.hpp:82
traits row_traits
Definition: pixel_buffer.hpp:68
void resize(size_t size)
Resizes the pixel row to hold up to size packed pixels.
Definition: pixel_buffer.hpp:350
static size_t get_pixels_per_byte()
Definition: pixel_buffer.hpp:262
packed_pixel_proxy(packed_pixel_proxy const &other)
Definition: pixel_buffer.hpp:294
size_t m_height
Definition: pixel_buffer.hpp:185
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:482
basic_packed_pixel_proxy(reference ref)
Definition: pixel_buffer.hpp:232
void put_row(size_t index, row_type const &r)
Replaces the row at specified index.
Definition: pixel_buffer.hpp:161
packed_pixel_proxy(byte &ref, size_t index)
Definition: pixel_buffer.hpp:289