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

## 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.

## 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 png::solid_pixel_buffer< pixel >::resize().

## Member Function Documentation

## get_width()

template<typename pixel >

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

inline

References png::solid_pixel_buffer< pixel >::m_width.

## get_height()

template<typename pixel >

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

inline

References png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::bytes_per_pixel, png::solid_pixel_buffer< pixel >::m_bytes, png::solid_pixel_buffer< pixel >::m_height, png::solid_pixel_buffer< pixel >::m_stride, and png::solid_pixel_buffer< pixel >::m_width.

Referenced by png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::m_stride.

Referenced by png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::get_row(), and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::bytes_per_pixel, png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::bytes_per_pixel, png::solid_pixel_buffer< pixel >::m_bytes, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::m_bytes, png::solid_pixel_buffer< pixel >::m_height, png::solid_pixel_buffer< pixel >::m_stride, and png::solid_pixel_buffer< pixel >::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 png::solid_pixel_buffer< pixel >::get_pixel(), png::solid_pixel_buffer< pixel >::resize(), and png::solid_pixel_buffer< pixel >::set_pixel().

## m_width

template<typename pixel >

uint_32 png::solid_pixel_buffer< pixel >::m_width

protected

Referenced by png::solid_pixel_buffer< pixel >::fetch_bytes(), png::solid_pixel_buffer< pixel >::get_pixel(), png::solid_pixel_buffer< pixel >::get_width(), png::solid_pixel_buffer< pixel >::put_row(), png::solid_pixel_buffer< pixel >::resize(), and png::solid_pixel_buffer< pixel >::set_pixel().

## m_height

template<typename pixel >

uint_32 png::solid_pixel_buffer< pixel >::m_height

protected

Referenced by png::solid_pixel_buffer< pixel >::fetch_bytes(), png::solid_pixel_buffer< pixel >::get_height(), and png::solid_pixel_buffer< pixel >::resize().

## m_stride

template<typename pixel >

size_t png::solid_pixel_buffer< pixel >::m_stride

protected

Referenced by png::solid_pixel_buffer< pixel >::fetch_bytes(), png::solid_pixel_buffer< pixel >::get_row(), png::solid_pixel_buffer< pixel >::operator[](), and png::solid_pixel_buffer< pixel >::resize().

## m_bytes

template<typename pixel >

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

protected

Referenced by png::solid_pixel_buffer< pixel >::fetch_bytes(), png::solid_pixel_buffer< pixel >::get_bytes(), png::solid_pixel_buffer< pixel >::get_pixel(), png::solid_pixel_buffer< pixel >::get_row(), png::solid_pixel_buffer< pixel >::operator[](), png::solid_pixel_buffer< pixel >::resize(), and png::solid_pixel_buffer< pixel >::set_pixel().

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

- solid_pixel_buffer.hpp