Pixel data container. More...
#include <pixel_buffer.h>
Public Member Functions | |
unsigned int | bytes_per_block () const |
Returns the number of bytes per compression block. More... | |
unsigned int | bytes_per_pixel () const |
Returns the number of bytes per pixel. More... | |
std::shared_ptr< PixelBuffer > | copy () const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. More... | |
std::shared_ptr< PixelBuffer > | copy (const Rect &rect) const |
virtual void * | data ()=0 |
Returns a pointer to the beginning of the pixel buffer. More... | |
virtual const void * | data () const =0 |
template<typename Type > | |
Type * | data () |
template<typename Type > | |
const Type * | data () const |
unsigned int | data_size () const |
Returns the size in bytes of the image data. More... | |
unsigned short * | data_uint16 () |
Returns a pointer to the beginning of the pixel buffer as 16 bit data. More... | |
const unsigned short * | data_uint16 () const |
unsigned int * | data_uint32 () |
Returns a pointer to the beginning of the pixel buffer as 32 bit data. More... | |
const unsigned int * | data_uint32 () const |
unsigned char * | data_uint8 () |
Returns a pointer to the beginning of the pixel buffer as 8 bit data. More... | |
const unsigned char * | data_uint8 () const |
float | dip_height () const |
Returns the device independent height of this texture. More... | |
Sizef | dip_size () const |
Returns the device independent size of this texture. More... | |
float | dip_width () const |
Returns the device independent width of this texture. More... | |
void | flip_vertical () |
Flip the entire image vertically (turn it upside down) More... | |
virtual TextureFormat | format () const =0 |
Returns the pixel format. More... | |
bool | has_transparency () const |
Returns true if format has an alpha channel. More... | |
virtual int | height () const =0 |
Retrieves the height of the buffer. More... | |
bool | is_compressed () const |
Returns true if compressed. More... | |
void * | line (int line) |
Returns a pointer to the beginning of a specific line. More... | |
const void * | line (int line) const |
template<typename T > | |
T * | line (int line) |
template<typename T > | |
const T * | line (int line) const |
unsigned short * | line_uint16 (int index) |
Returns a pointer to the beginning of a specific line as 16 bit data. More... | |
const unsigned short * | line_uint16 (int index) const |
unsigned int * | line_uint32 (int index) |
Returns a pointer to the beginning of a specific line as 32 bit data. More... | |
const unsigned int * | line_uint32 (int index) const |
unsigned char * | line_uint8 (int index) |
Returns a pointer to the beginning of a specific line as 8 bit data. More... | |
const unsigned char * | line_uint8 (int index) const |
virtual int | pitch () const =0 |
Returns the pitch (bytes allocated per row). More... | |
virtual float | pixel_ratio () const =0 |
void | premultiply_alpha () |
Multiply the RGB components by the Alpha component. More... | |
void | premultiply_gamma (float gamma) |
Multiply the RGB components by gamma value. More... | |
void | set_image (const std::shared_ptr< PixelBuffer > &source) |
Copy source pixel buffer into this buffer, doing a format conversion if needed. More... | |
void | set_image (const std::shared_ptr< PixelBuffer > &source, const PixelConverterPtr &converter) |
Copy source pixel buffer into this buffer, doing a format conversion if needed. More... | |
virtual void | set_pixel_ratio (float ratio)=0 |
Sets the display pixel ratio for this image. More... | |
void | set_subimage (const std::shared_ptr< PixelBuffer > &source, const Point &dest_pos, const Rect &src_rect) |
Copy source pixel buffer into this buffer, doing a format conversion if needed. More... | |
void | set_subimage (const std::shared_ptr< PixelBuffer > &source, const Point &dest_pos, const Rect &src_rect, const PixelConverterPtr &converter) |
Copy source pixel buffer into this buffer, doing a format conversion if needed. More... | |
Size | size () const |
Retrieves the size of the buffer. More... | |
std::shared_ptr< PixelBuffer > | to_format (TextureFormat texture_format) const |
Converts current buffer to a new pixel format and returns the result. More... | |
std::shared_ptr< PixelBuffer > | to_format (TextureFormat texture_format, const PixelConverterPtr &converter) const |
Converts current buffer to a new pixel format and returns the result. More... | |
virtual int | width () const =0 |
Retrieves the width of the buffer. More... | |
Static Public Member Functions | |
static std::shared_ptr< PixelBuffer > | add_border (const std::shared_ptr< PixelBuffer > &pb, int border_size, const Rect &rect) |
Add a border around a pixelbuffer, duplicating the edge pixels. More... | |
static unsigned int | bytes_per_block (TextureFormat texture_format) |
Returns the number of bytes per compression block. More... | |
static unsigned int | bytes_per_pixel (TextureFormat texture_format) |
Returns the number of bytes per pixel. More... | |
static std::shared_ptr< PixelBuffer > | create (int width, int height, TextureFormat texture_format, const void *data=nullptr, bool only_reference_data=false) |
Constructs a PixelBuffer. More... | |
static unsigned int | data_size (const Size &size, TextureFormat texture_format) |
Returns the size in bytes of the image data. More... | |
static bool | is_compressed (TextureFormat texture_format) |
Tests if the specified texture format is a compressed format. More... | |
Pixel data container.
|
static |
Add a border around a pixelbuffer, duplicating the edge pixels.
unsigned int uicore::PixelBuffer::bytes_per_block | ( | ) | const |
Returns the number of bytes per compression block.
|
static |
Returns the number of bytes per compression block.
unsigned int uicore::PixelBuffer::bytes_per_pixel | ( | ) | const |
Returns the number of bytes per pixel.
|
static |
Returns the number of bytes per pixel.
std::shared_ptr<PixelBuffer> uicore::PixelBuffer::copy | ( | ) | const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
std::shared_ptr<PixelBuffer> uicore::PixelBuffer::copy | ( | const Rect & | rect | ) | const |
|
static |
Constructs a PixelBuffer.
width | = value |
height | = value |
sized_format | = Pixel Format |
data | = The data (0 = Allocate automatically to a boundary of 16 bytes) |
only_reference_data | : true = Reference the data. false = Copy the data |
|
pure virtual |
Returns a pointer to the beginning of the pixel buffer.
Referenced by data_uint16(), data_uint32(), and data_uint8().
|
pure virtual |
|
inline |
|
inline |
unsigned int uicore::PixelBuffer::data_size | ( | ) | const |
Returns the size in bytes of the image data.
|
static |
Returns the size in bytes of the image data.
|
inline |
Returns a pointer to the beginning of the pixel buffer as 16 bit data.
References data().
|
inline |
References data().
|
inline |
Returns a pointer to the beginning of the pixel buffer as 32 bit data.
References data().
|
inline |
References data().
|
inline |
|
inline |
References data().
|
inline |
Returns the device independent height of this texture.
References height(), and pixel_ratio().
Referenced by dip_size().
|
inline |
Returns the device independent size of this texture.
References dip_height(), and dip_width().
|
inline |
Returns the device independent width of this texture.
References pixel_ratio(), and width().
Referenced by dip_size().
void uicore::PixelBuffer::flip_vertical | ( | ) |
Flip the entire image vertically (turn it upside down)
|
pure virtual |
Returns the pixel format.
bool uicore::PixelBuffer::has_transparency | ( | ) | const |
Returns true if format has an alpha channel.
|
pure virtual |
Retrieves the height of the buffer.
Referenced by dip_height(), and size().
bool uicore::PixelBuffer::is_compressed | ( | ) | const |
Returns true if compressed.
|
static |
Tests if the specified texture format is a compressed format.
|
inline |
Returns a pointer to the beginning of a specific line.
References uicore::d, data_uint8(), and pitch().
Referenced by line_uint16(), line_uint32(), and line_uint8().
|
inline |
References uicore::d, data_uint8(), and pitch().
|
inline |
References uicore::d, data_uint8(), and pitch().
|
inline |
References uicore::d, data_uint8(), and pitch().
|
inline |
Returns a pointer to the beginning of a specific line as 16 bit data.
References line().
|
inline |
References line().
|
inline |
Returns a pointer to the beginning of a specific line as 32 bit data.
References line().
|
inline |
References line().
|
inline |
Returns a pointer to the beginning of a specific line as 8 bit data.
References line().
|
inline |
References line().
|
pure virtual |
Returns the pitch (bytes allocated per row).
Referenced by line().
|
pure virtual |
Retrieves the pixel ratio of this image.
Referenced by dip_height(), and dip_width().
void uicore::PixelBuffer::premultiply_alpha | ( | ) |
Multiply the RGB components by the Alpha component.
This is useful with certain blending functions
void uicore::PixelBuffer::premultiply_gamma | ( | float | gamma | ) |
Multiply the RGB components by gamma value.
Calling this function with 2.2 gamma converts a sRGB image into linear space. To convert from linear to sRGB use 1.0/2.2
void uicore::PixelBuffer::set_image | ( | const std::shared_ptr< PixelBuffer > & | source | ) |
Copy source pixel buffer into this buffer, doing a format conversion if needed.
source | Source pixel buffer. |
void uicore::PixelBuffer::set_image | ( | const std::shared_ptr< PixelBuffer > & | source, |
const PixelConverterPtr & | converter | ||
) |
Copy source pixel buffer into this buffer, doing a format conversion if needed.
source | Source pixel buffer. |
|
pure virtual |
Sets the display pixel ratio for this image.
void uicore::PixelBuffer::set_subimage | ( | const std::shared_ptr< PixelBuffer > & | source, |
const Point & | dest_pos, | ||
const Rect & | src_rect | ||
) |
Copy source pixel buffer into this buffer, doing a format conversion if needed.
source | Source pixel buffer. |
dest_rect | Destination position for copy. |
src_rect | Source rectangle for copy. |
void uicore::PixelBuffer::set_subimage | ( | const std::shared_ptr< PixelBuffer > & | source, |
const Point & | dest_pos, | ||
const Rect & | src_rect, | ||
const PixelConverterPtr & | converter | ||
) |
Copy source pixel buffer into this buffer, doing a format conversion if needed.
source | Source pixel buffer. |
dest_rect | Destination position for copy. |
src_rect | Source rectangle for copy. |
|
inline |
std::shared_ptr<PixelBuffer> uicore::PixelBuffer::to_format | ( | TextureFormat | texture_format | ) | const |
Converts current buffer to a new pixel format and returns the result.
std::shared_ptr<PixelBuffer> uicore::PixelBuffer::to_format | ( | TextureFormat | texture_format, |
const PixelConverterPtr & | converter | ||
) | const |
Converts current buffer to a new pixel format and returns the result.
|
pure virtual |
Retrieves the width of the buffer.
Referenced by dip_width(), and size().