ClanLib
2.3.7
|
Pixel data container. More...
#include <pixel_buffer.h>
Public Member Functions | |
Construction | |
CL_PixelBuffer () | |
Constructs a null instance. More... | |
CL_PixelBuffer (int width, int height, CL_TextureFormat sized_format, const void *data=0, bool only_reference_data=false) | |
Constructs a PixelBuffer. More... | |
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. More... | |
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. More... | |
CL_PixelBuffer (int width, int height, CL_TextureFormat sized_format, const CL_Palette &palette, const void *data=0) | |
Constructs a PixelBuffer. More... | |
CL_PixelBuffer (const CL_StringRef &fullname) | |
Constructs a PixelBuffer. More... | |
CL_PixelBuffer (const CL_StringRef &filename, const CL_VirtualDirectory &dir) | |
Constructs a PixelBuffer. More... | |
CL_PixelBuffer (CL_IODevice &file, const CL_String &image_type) | |
Constructs a PixelBuffer. More... | |
virtual | ~CL_PixelBuffer () |
Attributes | |
bool | is_null () const |
Returns true if this object is invalid. More... | |
void | throw_if_null () const |
Throw an exception if this object is invalid. More... | |
CL_PixelBuffer | copy () const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. More... | |
CL_PixelBuffer | copy (const CL_Rect &rect) const |
Create a copy of the pixelbuffer that doesn't share data with the original pixel buffer. More... | |
const CL_Palette * | get_palette () const |
Returns the palette of the pixel buffer. More... | |
int | get_width () const |
Returns the buffer width. More... | |
int | get_height () const |
Returns the buffer height. More... | |
CL_Size | get_size () const |
Returns the width and height of the buffer. More... | |
unsigned int | get_pitch () const |
Returns the pitch (bytes per scanline). More... | |
void * | get_data () |
Returns a pointer to the beginning of the pixel buffer. More... | |
const void * | get_data () const |
unsigned char * | get_data_uint8 () |
Returns a pointer to the beginning of the pixel buffer as 8 bit data. More... | |
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. More... | |
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. More... | |
const unsigned int * | get_data_uint32 () const |
void * | get_line (int line) |
Returns a pointer to the beginning of a specific line. More... | |
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. More... | |
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. More... | |
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. More... | |
const unsigned int * | get_line_uint32 (int line) const |
bool | has_colorkey () const |
Returns true if format uses a source color key. More... | |
unsigned int | get_colorkey () const |
Returns the source color key. More... | |
int | get_bytes_per_pixel () const |
Returns the number of bytes per pixel. More... | |
unsigned int | get_red_mask () const |
Returns the red component color mask (if available) More... | |
unsigned int | get_green_mask () const |
Returns the green component color mask (if available) More... | |
unsigned int | get_blue_mask () const |
Returns the blue component color mask (if available) More... | |
unsigned int | get_alpha_mask () const |
Returns the alpha component color mask (if available) More... | |
CL_TextureFormat | get_format () const |
Returns the pixel format. More... | |
CL_PixelBufferProvider * | get_provider () const |
Get Provider. More... | |
CL_Colorf | get_pixel (int x, int y) |
Return color of pixel at the specified coordinates. More... | |
Operations | |
void | lock (CL_BufferAccess access) |
Maps buffer into system memory. More... | |
void | unlock () |
Unmaps element buffer. More... | |
void | upload_data (const CL_Rect &dest_rect, const void *data) |
Uploads data to buffer. More... | |
operator bool () const | |
Return true if the CL_PixelBuffer is valid and usable. More... | |
void | convert (CL_PixelBuffer &target) const |
Convert pixel buffer to the pixel format of the target buffer, storing the result in the target buffer. More... | |
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. More... | |
CL_PixelBuffer | to_format (CL_TextureFormat sized_format) const |
Converts current buffer to a new pixel format and returns the result. More... | |
void | set_colorkey (bool enabled, unsigned int colorkey) |
Sets a new colorkey without converting the buffer. More... | |
void | flip_vertical () |
Flip the entire image vertically (turn it upside down) More... | |
void | premultiply_alpha () |
Mutiply the RGB components by the Alpha component. More... | |
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 |
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 |
|
inline |
Returns a pointer to the beginning of the pixel buffer as 16 bit data.
|
inline |
|
inline |
Returns a pointer to the beginning of the pixel buffer as 32 bit data.
|
inline |
|
inline |
Returns a pointer to the beginning of the pixel buffer as 8 bit data.
|
inline |
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.
|
inline |
Returns a pointer to the beginning of a specific line.
|
inline |
|
inline |
Returns a pointer to the beginning of a specific line as 16 bit data.
|
inline |
|
inline |
Returns a pointer to the beginning of a specific line as 32 bit data.
|
inline |
|
inline |
Returns a pointer to the beginning of a specific line as 8 bit data.
|
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.
|
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 |