uicore::PixelBuffer Class Referenceabstract

Pixel data container. More...

#include <pixel_buffer.h>

+ Inheritance diagram for uicore::PixelBuffer:

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< PixelBuffercopy () const
 Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. More...
 
std::shared_ptr< PixelBuffercopy (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< PixelBufferto_format (TextureFormat texture_format) const
 Converts current buffer to a new pixel format and returns the result. More...
 
std::shared_ptr< PixelBufferto_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< PixelBufferadd_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< PixelBuffercreate (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...
 

Detailed Description

Pixel data container.

Member Function Documentation

static std::shared_ptr<PixelBuffer> uicore::PixelBuffer::add_border ( const std::shared_ptr< PixelBuffer > &  pb,
int  border_size,
const Rect rect 
)
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.

Returns
Bytes per block. Exception thrown if not available (hint, use is_compressed() )
static unsigned int uicore::PixelBuffer::bytes_per_block ( TextureFormat  texture_format)
static

Returns the number of bytes per compression block.

Returns
Bytes per block. Exception thrown if not available (hint, use is_compressed() )
unsigned int uicore::PixelBuffer::bytes_per_pixel ( ) const

Returns the number of bytes per pixel.

Returns
Bytes per pixel. Exception thrown if not available (hint, use is_compressed() )
static unsigned int uicore::PixelBuffer::bytes_per_pixel ( TextureFormat  texture_format)
static

Returns the number of bytes per pixel.

Returns
Bytes per pixel. Exception thrown if not available (hint, use is_compressed() )
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 std::shared_ptr<PixelBuffer> uicore::PixelBuffer::create ( int  width,
int  height,
TextureFormat  texture_format,
const void *  data = nullptr,
bool  only_reference_data = false 
)
static

Constructs a PixelBuffer.

Parameters
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
virtual void* uicore::PixelBuffer::data ( )
pure virtual

Returns a pointer to the beginning of the pixel buffer.

Referenced by data_uint16(), data_uint32(), and data_uint8().

virtual const void* uicore::PixelBuffer::data ( ) const
pure virtual
template<typename Type >
Type* uicore::PixelBuffer::data ( )
inline

References data().

Referenced by data().

template<typename Type >
const Type* uicore::PixelBuffer::data ( ) const
inline

References data().

Referenced by data().

unsigned int uicore::PixelBuffer::data_size ( ) const

Returns the size in bytes of the image data.

Returns
The data size
static unsigned int uicore::PixelBuffer::data_size ( const Size size,
TextureFormat  texture_format 
)
static

Returns the size in bytes of the image data.

Returns
The data size
unsigned short* uicore::PixelBuffer::data_uint16 ( )
inline

Returns a pointer to the beginning of the pixel buffer as 16 bit data.

References data().

const unsigned short* uicore::PixelBuffer::data_uint16 ( ) const
inline

References data().

unsigned int* uicore::PixelBuffer::data_uint32 ( )
inline

Returns a pointer to the beginning of the pixel buffer as 32 bit data.

References data().

const unsigned int* uicore::PixelBuffer::data_uint32 ( ) const
inline

References data().

unsigned char* uicore::PixelBuffer::data_uint8 ( )
inline

Returns a pointer to the beginning of the pixel buffer as 8 bit data.

References data().

Referenced by line().

const unsigned char* uicore::PixelBuffer::data_uint8 ( ) const
inline

References data().

float uicore::PixelBuffer::dip_height ( ) const
inline

Returns the device independent height of this texture.

References height(), and pixel_ratio().

Referenced by dip_size().

Sizef uicore::PixelBuffer::dip_size ( ) const
inline

Returns the device independent size of this texture.

References dip_height(), and dip_width().

float uicore::PixelBuffer::dip_width ( ) const
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)

virtual TextureFormat uicore::PixelBuffer::format ( ) const
pure virtual

Returns the pixel format.

bool uicore::PixelBuffer::has_transparency ( ) const

Returns true if format has an alpha channel.

virtual int uicore::PixelBuffer::height ( ) const
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 bool uicore::PixelBuffer::is_compressed ( TextureFormat  texture_format)
static

Tests if the specified texture format is a compressed format.

void* uicore::PixelBuffer::line ( int  line)
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().

const void* uicore::PixelBuffer::line ( int  line) const
inline

References uicore::d, data_uint8(), and pitch().

template<typename T >
T* uicore::PixelBuffer::line ( int  line)
inline

References uicore::d, data_uint8(), and pitch().

template<typename T >
const T* uicore::PixelBuffer::line ( int  line) const
inline

References uicore::d, data_uint8(), and pitch().

unsigned short* uicore::PixelBuffer::line_uint16 ( int  index)
inline

Returns a pointer to the beginning of a specific line as 16 bit data.

References line().

const unsigned short* uicore::PixelBuffer::line_uint16 ( int  index) const
inline

References line().

unsigned int* uicore::PixelBuffer::line_uint32 ( int  index)
inline

Returns a pointer to the beginning of a specific line as 32 bit data.

References line().

const unsigned int* uicore::PixelBuffer::line_uint32 ( int  index) const
inline

References line().

unsigned char* uicore::PixelBuffer::line_uint8 ( int  index)
inline

Returns a pointer to the beginning of a specific line as 8 bit data.

References line().

const unsigned char* uicore::PixelBuffer::line_uint8 ( int  index) const
inline

References line().

virtual int uicore::PixelBuffer::pitch ( ) const
pure virtual

Returns the pitch (bytes allocated per row).

Referenced by line().

virtual float uicore::PixelBuffer::pixel_ratio ( ) const
pure virtual

Retrieves the pixel ratio of this image.

Returns
The display pixel ratio set for this image. A zero value implies that no pixel ratio has been set

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.

Parameters
sourceSource 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.

Parameters
sourceSource pixel buffer.
virtual void uicore::PixelBuffer::set_pixel_ratio ( float  ratio)
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.

Parameters
sourceSource pixel buffer.
dest_rectDestination position for copy.
src_rectSource 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.

Parameters
sourceSource pixel buffer.
dest_rectDestination position for copy.
src_rectSource rectangle for copy.
Size uicore::PixelBuffer::size ( ) const
inline

Retrieves the size of the buffer.

References height(), and width().

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.

virtual int uicore::PixelBuffer::width ( ) const
pure virtual

Retrieves the width of the buffer.

Referenced by dip_width(), and size().


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