Pixel data container. More...
#include <pixel_buffer.h>
Public Member Functions | |
Construction | |
CL_PixelBuffer () | |
Constructs a null instance. | |
CL_PixelBuffer (int width, int height, CL_TextureFormat sized_format, const void *data=0, bool only_reference_data=false) | |
Constructs a PixelBuffer. | |
CL_PixelBuffer (CL_GraphicContext &gc, int width, int height, CL_PixelBufferDirection direction=cl_data_to_gpu, CL_TextureFormat sized_format=cl_rgba8, const void *data=0, CL_BufferUsage usage=cl_usage_stream_draw) | |
Constructs a GPU PixelBuffer. | |
CL_PixelBuffer (CL_GraphicContext &gc, const CL_PixelBuffer &pbuff, CL_PixelBufferDirection direction=cl_data_to_gpu, CL_BufferUsage usage=cl_usage_stream_draw) | |
Constructs a GPU PixelBuffer from an existing pixelbuffer. | |
CL_PixelBuffer (int width, int height, CL_TextureFormat sized_format, const CL_Palette &palette, const void *data=0) | |
Constructs a PixelBuffer. | |
CL_PixelBuffer (const CL_StringRef &fullname) | |
Constructs a PixelBuffer. | |
CL_PixelBuffer (const CL_StringRef &filename, const CL_VirtualDirectory &dir) | |
Constructs a PixelBuffer. | |
CL_PixelBuffer (CL_IODevice &file, const CL_String &image_type) | |
Constructs a PixelBuffer. | |
virtual | ~CL_PixelBuffer () |
Attributes | |
bool | is_null () const |
Returns true if this object is invalid. | |
void | throw_if_null () const |
Throw an exception if this object is invalid. | |
CL_PixelBuffer | copy () const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. | |
CL_PixelBuffer | copy (const CL_Rect &rect) const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. | |
const CL_Palette * | get_palette () const |
Returns the palette of the pixel buffer. | |
int | get_width () const |
Returns the buffer width. | |
int | get_height () const |
Returns the buffer height. | |
CL_Size | get_size () const |
Returns the width and height of the buffer. | |
unsigned int | get_pitch () const |
Returns the pitch (bytes per scanline). | |
void * | get_data () |
Returns a pointer to the beginning of the pixel buffer. | |
const void * | get_data () const |
unsigned char * | get_data_uint8 () |
Returns a pointer to the beginning of the pixel buffer as 8 bit data. | |
const unsigned char * | get_data_uint8 () const |
unsigned short * | get_data_uint16 () |
Returns a pointer to the beginning of the pixel buffer as 16 bit data. | |
const unsigned short * | get_data_uint16 () const |
unsigned int * | get_data_uint32 () |
Returns a pointer to the beginning of the pixel buffer as 32 bit data. | |
const unsigned int * | get_data_uint32 () const |
void * | get_line (int line) |
Returns a pointer to the beginning of a specific line. | |
const void * | get_line (int line) const |
unsigned char * | get_line_uint8 (int line) |
Returns a pointer to the beginning of a specific line as 8 bit data. | |
const unsigned char * | get_line_uint8 (int line) const |
unsigned short * | get_line_uint16 (int line) |
Returns a pointer to the beginning of a specific line as 16 bit data. | |
const unsigned short * | get_line_uint16 (int line) const |
unsigned int * | get_line_uint32 (int line) |
Returns a pointer to the beginning of a specific line as 32 bit data. | |
const unsigned int * | get_line_uint32 (int line) const |
bool | has_colorkey () const |
Returns true if format uses a source color key. | |
unsigned int | get_colorkey () const |
Returns the source color key. | |
int | get_bytes_per_pixel () const |
Returns the number of bytes per pixel. | |
unsigned int | get_red_mask () const |
Returns the red component color mask (if available). | |
unsigned int | get_green_mask () const |
Returns the green component color mask (if available). | |
unsigned int | get_blue_mask () const |
Returns the blue component color mask (if available). | |
unsigned int | get_alpha_mask () const |
Returns the alpha component color mask (if available). | |
CL_TextureFormat | get_format () const |
Returns the pixel format. | |
CL_PixelBufferProvider * | get_provider () const |
Get Provider. | |
CL_Colorf | get_pixel (int x, int y) |
Return color of pixel at the specified coordinates. | |
Operations | |
void | lock (CL_BufferAccess access) |
Maps buffer into system memory. | |
void | unlock () |
Unmaps element buffer. | |
void | upload_data (const CL_Rect &dest_rect, const void *data) |
Uploads data to buffer. | |
operator bool () const | |
Return true if the CL_PixelBuffer is valid and usable. | |
void | convert (CL_PixelBuffer &target) const |
Convert pixel buffer to the pixel format of the target buffer, storing the result in the target buffer. | |
void | convert (CL_PixelBuffer &target, const CL_Rect &dest_rect, const CL_Rect &src_rect=CL_Rect()) const |
Convert pixel buffer to the pixel format of the target buffer, storing the result in the target buffer. | |
CL_PixelBuffer | to_format (CL_TextureFormat sized_format) const |
Converts current buffer to a new pixel format and returns the result. | |
void | set_colorkey (bool enabled, unsigned int colorkey) |
Sets a new colorkey without converting the buffer. | |
void | flip_vertical () |
Flip the entire image vertically (turn it upside down). | |
void | premultiply_alpha () |
Mutiply the RGB components by the Alpha component. | |
Implementation | |
| |
class | CL_PixelBuffer_Impl |
Pixel data container.
CL_PixelBuffer::CL_PixelBuffer | ( | ) |
Constructs a null instance.
CL_PixelBuffer::CL_PixelBuffer | ( | int | width, | |
int | height, | |||
CL_TextureFormat | sized_format, | |||
const void * | data = 0 , |
|||
bool | only_reference_data = false | |||
) |
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 |
CL_PixelBuffer::CL_PixelBuffer | ( | CL_GraphicContext & | gc, | |
int | width, | |||
int | height, | |||
CL_PixelBufferDirection | direction = cl_data_to_gpu , |
|||
CL_TextureFormat | sized_format = cl_rgba8 , |
|||
const void * | data = 0 , |
|||
CL_BufferUsage | usage = cl_usage_stream_draw | |||
) |
Constructs a GPU PixelBuffer.
gc | = Graphic Context | |
width | = value | |
height | = value | |
direction | = prefered direction that you will use tranferring the pixel buffer data | |
sized_format | = Texture Format | |
data | = data to copy from (May be NULL) | |
usage | = Buffer Usage |
CL_PixelBuffer::CL_PixelBuffer | ( | CL_GraphicContext & | gc, | |
const CL_PixelBuffer & | pbuff, | |||
CL_PixelBufferDirection | direction = cl_data_to_gpu , |
|||
CL_BufferUsage | usage = cl_usage_stream_draw | |||
) |
Constructs a GPU PixelBuffer from an existing pixelbuffer.
gc | = Graphic Context | |
pbuff | = The pixelbuffer to copy from | |
direction | = prefered direction that you will use tranferring the pixel buffer data | |
usage | = Buffer Usage |
CL_PixelBuffer::CL_PixelBuffer | ( | int | width, | |
int | height, | |||
CL_TextureFormat | sized_format, | |||
const CL_Palette & | palette, | |||
const void * | data = 0 | |||
) |
Constructs a PixelBuffer.
width | = value | |
height | = value | |
sized_format | = Pixel Format | |
palette | = Palette | |
data | = void |
CL_PixelBuffer::CL_PixelBuffer | ( | const CL_StringRef & | fullname | ) |
Constructs a PixelBuffer.
fullname | = String Ref |
CL_PixelBuffer::CL_PixelBuffer | ( | const CL_StringRef & | filename, | |
const CL_VirtualDirectory & | dir | |||
) |
Constructs a PixelBuffer.
filename | = String Ref | |
dir | = Virtual Directory |
CL_PixelBuffer::CL_PixelBuffer | ( | CL_IODevice & | file, | |
const CL_String & | image_type | |||
) |
Constructs a PixelBuffer.
file | = IODevice | |
image_type | = String |
virtual CL_PixelBuffer::~CL_PixelBuffer | ( | ) | [virtual] |
void CL_PixelBuffer::convert | ( | CL_PixelBuffer & | target | ) | const |
Convert pixel buffer to the pixel format of the target buffer, storing the result in the target buffer.
target | Target pixel buffer. |
void CL_PixelBuffer::convert | ( | CL_PixelBuffer & | target, | |
const CL_Rect & | dest_rect, | |||
const CL_Rect & | src_rect = CL_Rect() | |||
) | const |
Convert pixel buffer to the pixel format of the target buffer, storing the result in the target buffer.
target | Buffer getting stored pixels in the specified format and pitch. | |
dest_rect | Destination rectangle for conversion. | |
src_rect | Source rectangle for conversion. |
CL_PixelBuffer CL_PixelBuffer::copy | ( | ) | const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
CL_PixelBuffer CL_PixelBuffer::copy | ( | const CL_Rect & | rect | ) | const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer.
void CL_PixelBuffer::flip_vertical | ( | ) |
Flip the entire image vertically (turn it upside down).
unsigned int CL_PixelBuffer::get_alpha_mask | ( | ) | const |
Returns the alpha component color mask (if available).
unsigned int CL_PixelBuffer::get_blue_mask | ( | ) | const |
Returns the blue component color mask (if available).
int CL_PixelBuffer::get_bytes_per_pixel | ( | ) | const |
Returns the number of bytes per pixel.
unsigned int CL_PixelBuffer::get_colorkey | ( | ) | const |
Returns the source color key.
void* CL_PixelBuffer::get_data | ( | ) |
Returns a pointer to the beginning of the pixel buffer.
Referenced by CL_PixelBufferData::set().
const void* CL_PixelBuffer::get_data | ( | ) | const |
unsigned short* CL_PixelBuffer::get_data_uint16 | ( | ) | [inline] |
Returns a pointer to the beginning of the pixel buffer as 16 bit data.
const unsigned short* CL_PixelBuffer::get_data_uint16 | ( | ) | const [inline] |
unsigned int* CL_PixelBuffer::get_data_uint32 | ( | ) | [inline] |
Returns a pointer to the beginning of the pixel buffer as 32 bit data.
const unsigned int* CL_PixelBuffer::get_data_uint32 | ( | ) | const [inline] |
const unsigned char* CL_PixelBuffer::get_data_uint8 | ( | ) | const [inline] |
unsigned char* CL_PixelBuffer::get_data_uint8 | ( | ) | [inline] |
Returns a pointer to the beginning of the pixel buffer as 8 bit data.
CL_TextureFormat CL_PixelBuffer::get_format | ( | ) | const |
Returns the pixel format.
unsigned int CL_PixelBuffer::get_green_mask | ( | ) | const |
Returns the green component color mask (if available).
int CL_PixelBuffer::get_height | ( | ) | const |
Returns the buffer height.
void* CL_PixelBuffer::get_line | ( | int | line | ) | [inline] |
Returns a pointer to the beginning of a specific line.
const void* CL_PixelBuffer::get_line | ( | int | line | ) | const [inline] |
unsigned short* CL_PixelBuffer::get_line_uint16 | ( | int | line | ) | [inline] |
Returns a pointer to the beginning of a specific line as 16 bit data.
const unsigned short* CL_PixelBuffer::get_line_uint16 | ( | int | line | ) | const [inline] |
unsigned int* CL_PixelBuffer::get_line_uint32 | ( | int | line | ) | [inline] |
Returns a pointer to the beginning of a specific line as 32 bit data.
const unsigned int* CL_PixelBuffer::get_line_uint32 | ( | int | line | ) | const [inline] |
unsigned char* CL_PixelBuffer::get_line_uint8 | ( | int | line | ) | [inline] |
Returns a pointer to the beginning of a specific line as 8 bit data.
const unsigned char* CL_PixelBuffer::get_line_uint8 | ( | int | line | ) | const [inline] |
const CL_Palette* CL_PixelBuffer::get_palette | ( | ) | const |
Returns the palette of the pixel buffer.
unsigned int CL_PixelBuffer::get_pitch | ( | ) | const |
Returns the pitch (bytes per scanline).
CL_Colorf CL_PixelBuffer::get_pixel | ( | int | x, | |
int | y | |||
) |
Return color of pixel at the specified coordinates.
CL_PixelBufferProvider* CL_PixelBuffer::get_provider | ( | ) | const |
Get Provider.
unsigned int CL_PixelBuffer::get_red_mask | ( | ) | const |
Returns the red component color mask (if available).
CL_Size CL_PixelBuffer::get_size | ( | ) | const |
Returns the width and height of the buffer.
Referenced by CL_PixelBufferData::set().
int CL_PixelBuffer::get_width | ( | ) | const |
Returns the buffer width.
bool CL_PixelBuffer::has_colorkey | ( | ) | const |
Returns true if format uses a source color key.
bool CL_PixelBuffer::is_null | ( | ) | const [inline] |
Returns true if this object is invalid.
Referenced by CL_PixelBufferData::set().
void CL_PixelBuffer::lock | ( | CL_BufferAccess | access | ) |
Maps buffer into system memory.
CL_PixelBuffer::operator bool | ( | ) | const |
Return true if the CL_PixelBuffer is valid and usable.
void CL_PixelBuffer::premultiply_alpha | ( | ) |
Mutiply the RGB components by the Alpha component.
This is useful with certain blending functions
void CL_PixelBuffer::set_colorkey | ( | bool | enabled, | |
unsigned int | colorkey | |||
) |
Sets a new colorkey without converting the buffer.
(Used when converting from a format without an alpha channel)
enabled | Enable or disable the colorkey. | |
colorkey | New colorkey to use. |
void CL_PixelBuffer::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.
CL_PixelBuffer CL_PixelBuffer::to_format | ( | CL_TextureFormat | sized_format | ) | const |
Converts current buffer to a new pixel format and returns the result.
void CL_PixelBuffer::unlock | ( | ) |
Unmaps element buffer.
void CL_PixelBuffer::upload_data | ( | const CL_Rect & | dest_rect, | |
const void * | data | |||
) |
Uploads data to buffer.
friend class CL_PixelBuffer_Impl [friend] |