png++ 0.2.10

Classes | Public Types | Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
png::solid_pixel_buffer< pixel > Class Template Reference

Pixel buffer, that stores pixels as continuous memory chunk. solid_pixel_buffer is useful when user whats to open png, do some changes and fetch to buffer to draw (as texture for example). More...

`#include <solid_pixel_buffer.hpp>`

## Classes
struct | row_traits

## Public Types
typedef pixel_traits< pixel > | pixel_traits_t
typedef row_traits::row_access | row_access
| A row of pixel data.
typedef row_traits::row_const_access | row_const_access
typedef row_access | row_type

## Public Member Functions
| solid_pixel_buffer ()
| Constructs an empty 0x0 pixel buffer object.
| solid_pixel_buffer (uint_32 width, uint_32 height)
| Constructs an empty pixel buffer object.
uint_32 | get_width () const
uint_32 | get_height () const
void | resize (uint_32 width, uint_32 height)
| Resizes the pixel buffer.
row_access | get_row (size_t index)
| Returns a reference to the row of image data at specified index.
row_const_access | get_row (size_t index) const
| Returns a const reference to the row of image data at specified index.
row_access | operator[] (size_t index)
| The non-checking version of get_row() method.
row_const_access | operator[] (size_t index) const
| The non-checking version of get_row() method.
void | put_row (size_t index, row_const_access r)
| Replaces the row at specified index.
pixel | get_pixel (size_t x, size_t y) const
| Returns a pixel at (x,y) position.
void | set_pixel (size_t x, size_t y, pixel p)
| Replaces a pixel at (x,y) position.
const std::vector< byte > & | get_bytes () const
| Provides easy constant read access to underlying byte-buffer.
std::vector< byte > | fetch_bytes ()
| Moves the buffer to client code (c++11 only) .

## Protected Attributes
uint_32 | m_width
uint_32 | m_height
size_t | m_stride
std::vector< byte > | m_bytes

## Static Protected Attributes
static const size_t | bytes_per_pixel

## Detailed Description

template<typename pixel>
class png::solid_pixel_buffer< pixel >

Pixel buffer, that stores pixels as continuous memory chunk. solid_pixel_buffer is useful when user whats to open png, do some changes and fetch to buffer to draw (as texture for example).

## Member Typedef Documentation

## ◆ pixel_traits_t

template<typename pixel>

typedef pixel_traits< pixel > png::solid_pixel_buffer< pixel >::pixel_traits_t

## ◆ row_access

template<typename pixel>

typedef row_traits::row_access png::solid_pixel_buffer< pixel >::row_access

A row of pixel data.

## ◆ row_const_access

template<typename pixel>

typedef row_traits::row_const_access png::solid_pixel_buffer< pixel >::row_const_access

## ◆ row_type

template<typename pixel>

typedef row_access png::solid_pixel_buffer< pixel >::row_type

## Constructor & Destructor Documentation

## ◆ solid_pixel_buffer() [1/2]

template<typename pixel>

png::solid_pixel_buffer< pixel >::solid_pixel_buffer | ( |  | ) |
| inline

Constructs an empty 0x0 pixel buffer object.

References m_height, m_stride, and m_width.

## ◆ solid_pixel_buffer() [2/2]

template<typename pixel>

png::solid_pixel_buffer< pixel >::solid_pixel_buffer | ( | uint_32 | width,
|  | uint_32 | height )
| inline

Constructs an empty pixel buffer object.

References m_height, m_stride, m_width, and resize().

## Member Function Documentation

## ◆ get_width()

template<typename pixel>

uint_32 png::solid_pixel_buffer< pixel >::get_width | ( |  | ) | const
| inline

References m_width.

## ◆ get_height()

template<typename pixel>

uint_32 png::solid_pixel_buffer< pixel >::get_height | ( |  | ) | const
| inline

References m_height.

## ◆ resize()

template<typename pixel>

void png::solid_pixel_buffer< pixel >::resize | ( | uint_32 | width,
|  | uint_32 | height )
| inline

Resizes the pixel buffer.

If new width or height is greater than the original, expanded pixels are filled with value of pixel().

References bytes_per_pixel, m_bytes, m_height, m_stride, and m_width.

Referenced by solid_pixel_buffer().

## ◆ get_row() [1/2]

template<typename pixel>

row_access png::solid_pixel_buffer< pixel >::get_row | ( | size_t | index | ) |
| inline

Returns a reference to the row of image data at specified index.

Checks the index before returning a row: an instance of std::out_of_range is thrown if `index` is greater than `height`.

References m_bytes, and m_stride.

Referenced by put_row().

## ◆ get_row() [2/2]

template<typename pixel>

row_const_access png::solid_pixel_buffer< pixel >::get_row | ( | size_t | index | ) | const
| inline

Returns a const reference to the row of image data at specified index.

The checking version.

References m_bytes, and m_stride.

## ◆ operator[]() [1/2]

template<typename pixel>

row_access png::solid_pixel_buffer< pixel >::operator[] | ( | size_t | index | ) |
| inline

The non-checking version of get_row() method.

References m_bytes, and m_stride.

## ◆ operator[]() [2/2]

template<typename pixel>

row_const_access png::solid_pixel_buffer< pixel >::operator[] | ( | size_t | index | ) | const
| inline

The non-checking version of get_row() method.

References m_bytes, and m_stride.

## ◆ put_row()

template<typename pixel>

void png::solid_pixel_buffer< pixel >::put_row | ( | size_t | index,
|  | row_const_access | r )
| inline

Replaces the row at specified index.

References get_row(), and m_width.

## ◆ get_pixel()

template<typename pixel>

pixel png::solid_pixel_buffer< pixel >::get_pixel | ( | size_t | x,
|  | size_t | y ) const
| inline

Returns a pixel at (x,y) position.

References bytes_per_pixel, m_bytes, and m_width.

## ◆ set_pixel()

template<typename pixel>

void png::solid_pixel_buffer< pixel >::set_pixel | ( | size_t | x,
|  | size_t | y,
|  | pixel | p )
| inline

Replaces a pixel at (x,y) position.

References bytes_per_pixel, m_bytes, and m_width.

## ◆ get_bytes()

template<typename pixel>

const std::vector< byte > & png::solid_pixel_buffer< pixel >::get_bytes | ( |  | ) | const
| inline

Provides easy constant read access to underlying byte-buffer.

References m_bytes.

## ◆ fetch_bytes()

template<typename pixel>

std::vector< byte > png::solid_pixel_buffer< pixel >::fetch_bytes | ( |  | ) |
| inline

Moves the buffer to client code (c++11 only) .

References m_bytes, m_height, m_stride, and m_width.

## Member Data Documentation

## ◆ bytes_per_pixel

template<typename pixel>

const size_t png::solid_pixel_buffer< pixel >::bytes_per_pixel
| static protected

Initial value:
= pixel_traits_t::channels *
pixel_traits_t::bit_depth / CHAR_BIT

Referenced by get_pixel(), resize(), and set_pixel().

## ◆ m_width

template<typename pixel>

uint_32 png::solid_pixel_buffer< pixel >::m_width
| protected

Referenced by fetch_bytes(), get_pixel(), get_width(), put_row(), resize(), set_pixel(), solid_pixel_buffer(), and solid_pixel_buffer().

## ◆ m_height

template<typename pixel>

uint_32 png::solid_pixel_buffer< pixel >::m_height
| protected

Referenced by fetch_bytes(), get_height(), resize(), solid_pixel_buffer(), and solid_pixel_buffer().

## ◆ m_stride

template<typename pixel>

size_t png::solid_pixel_buffer< pixel >::m_stride
| protected

Referenced by fetch_bytes(), get_row(), get_row(), operator[](), operator[](), resize(), solid_pixel_buffer(), and solid_pixel_buffer().

## ◆ m_bytes

template<typename pixel>

std::vector< byte > png::solid_pixel_buffer< pixel >::m_bytes
| protected

Referenced by fetch_bytes(), get_bytes(), get_pixel(), get_row(), get_row(), operator[](), operator[](), resize(), and set_pixel().

The documentation for this class was generated from the following file:

- solid_pixel_buffer.hpp