Image class. More...
#include <image.h>
Public Member Functions | |
Construction | |
CL_Image () | |
Constructs a null instance. | |
CL_Image (CL_GraphicContext &context, CL_Texture texture, CL_Rect rect) | |
Constructs an image from a texture. | |
CL_Image (CL_GraphicContext &context, CL_Subtexture &sub_texture) | |
Constructs an image from a subtexture. | |
CL_Image (CL_GraphicContext &gc, const CL_PixelBuffer &pixelbuffer, const CL_Rect &rect) | |
Constructs a Image from a pixelbuffer. | |
CL_Image (CL_GraphicContext &context, const CL_StringRef &filename, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) | |
Constructs a Image. | |
CL_Image (CL_GraphicContext &context, const CL_StringRef &filename, CL_VirtualDirectory &dir, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) | |
Constructs a Image. | |
CL_Image (CL_GraphicContext &context, const CL_StringRef &resource_id, CL_ResourceManager *resources, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) | |
Constructs a Image. | |
virtual | ~CL_Image () |
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. | |
float | get_scale_x () const |
Returns x scale. | |
float | get_scale_y () const |
Returns y scale. | |
float | get_alpha () const |
Returns current alpha. | |
CL_Colorf | get_color () const |
Returns current color. | |
void | get_alignment (CL_Origin &origin, int &x, int &y) const |
Returns translation hot-spot. | |
CL_Size | get_size () const |
Get Size. | |
int | get_width () const |
Return the width of the image. | |
int | get_height () const |
Return the height of the image. | |
Operators | |
bool | operator== (const CL_Image &other) const |
Equality operator. | |
bool | operator!= (const CL_Image &other) const |
Inequality operator. | |
bool | operator< (const CL_Image &other) const |
Less than operator. | |
Operations | |
void | draw (CL_GraphicContext &gc, float x, float y) const |
Draw image on graphic context. | |
void | draw (CL_GraphicContext &gc, int x, int y) const |
Draw image on graphic context. | |
void | draw (CL_GraphicContext &gc, const CL_Rectf &src, const CL_Rectf &dest) const |
Draw image on graphic context. | |
void | draw (CL_GraphicContext &gc, const CL_Rectf &dest) const |
Draw image on graphic context. | |
void | set_scale (float x, float y) |
Set scale for x and y directions individually. | |
void | set_alpha (float alpha) |
Sets transparency. | |
void | set_color (const CL_Colorf &color) |
Sets the color. | |
void | set_color (const CL_Color &c) |
Set color. | |
void | set_alignment (CL_Origin origin, int x=0, int y=0) |
Sets translation hotspot. | |
void | set_wrap_mode (CL_TextureWrapMode wrap_s, CL_TextureWrapMode wrap_t) |
void | set_linear_filter (bool linear_filter=true) |
Set to true if a linear filter should be used for scaling up and down, false if a nearest-point filter should be used. | |
void | set_subimage (int x, int y, const CL_PixelBuffer &image, const CL_Rect &src_rect, int level=0) |
Upload image to sub texture. |
Image class.
CL_Image::CL_Image | ( | ) |
Constructs a null instance.
CL_Image::CL_Image | ( | CL_GraphicContext & | context, | |
CL_Texture | texture, | |||
CL_Rect | rect | |||
) |
Constructs an image from a texture.
context | = Graphic Context | |
texture | = Texture to get image data from | |
rect | = Position and size in texture to get image data from |
CL_Image::CL_Image | ( | CL_GraphicContext & | context, | |
CL_Subtexture & | sub_texture | |||
) |
Constructs an image from a subtexture.
context | = Graphic Context | |
sub_texture | = Subtexture to get image data from |
CL_Image::CL_Image | ( | CL_GraphicContext & | gc, | |
const CL_PixelBuffer & | pixelbuffer, | |||
const CL_Rect & | rect | |||
) |
Constructs a Image from a pixelbuffer.
gc | = Graphic Context | |
pixelbuffer | = Pixelbuffer to get image data from | |
rect | = pixelbuffer rect |
CL_Image::CL_Image | ( | CL_GraphicContext & | context, | |
const CL_StringRef & | filename, | |||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() | |||
) |
Constructs a Image.
context | = Graphic Context | |
filename | Filename of image to load | |
import_desc | = Image Import Description |
CL_Image::CL_Image | ( | CL_GraphicContext & | context, | |
const CL_StringRef & | filename, | |||
CL_VirtualDirectory & | dir, | |||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() | |||
) |
Constructs a Image.
context | = Graphic Context | |
filename | Filename of image to load | |
dir | = Virtual directory to load filename from | |
import_desc | = Image Import Description |
CL_Image::CL_Image | ( | CL_GraphicContext & | context, | |
const CL_StringRef & | resource_id, | |||
CL_ResourceManager * | resources, | |||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() | |||
) |
Constructs a Image.
context | = Graphic Context | |
resource_id | Resource name of the image resource | |
resources | Resource manager used to load resource | |
import_desc | = Image Import Description |
virtual CL_Image::~CL_Image | ( | ) | [virtual] |
void CL_Image::draw | ( | CL_GraphicContext & | gc, | |
float | x, | |||
float | y | |||
) | const |
Draw image on graphic context.
x,y | Anchor position of where to render image. Actual rendering position depends on the anchor and the alignment mode. | |
gc | Graphic context on which to render upon. |
void CL_Image::draw | ( | CL_GraphicContext & | gc, | |
const CL_Rectf & | src, | |||
const CL_Rectf & | dest | |||
) | const |
Draw image on graphic context.
gc | Graphic context on which to render upon. | |
src | Source rectangle to draw. Use this is draw only part of the image. | |
dest | Rectangle to draw image in. |
void CL_Image::draw | ( | CL_GraphicContext & | gc, | |
const CL_Rectf & | dest | |||
) | const |
Draw image on graphic context.
gc | Graphic context on which to render upon. | |
dest | Rectangle to draw image in. |
void CL_Image::draw | ( | CL_GraphicContext & | gc, | |
int | x, | |||
int | y | |||
) | const |
Draw image on graphic context.
x,y | Anchor position of where to render image. Actual rendering position depends on the anchor and the alignment mode. | |
gc | Graphic context on which to render upon. |
void CL_Image::get_alignment | ( | CL_Origin & | origin, | |
int & | x, | |||
int & | y | |||
) | const |
Returns translation hot-spot.
float CL_Image::get_alpha | ( | ) | const |
Returns current alpha.
Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).
CL_Colorf CL_Image::get_color | ( | ) | const |
Returns current color.
Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).
int CL_Image::get_height | ( | ) | const |
Return the height of the image.
float CL_Image::get_scale_x | ( | ) | const |
Returns x scale.
1.0f is normal scale, 2.0f is twice the size, etc.
float CL_Image::get_scale_y | ( | ) | const |
Returns y scale.
1.0f is normal scale, 2.0f is twice the size, etc.
CL_Size CL_Image::get_size | ( | ) | const |
Get Size.
int CL_Image::get_width | ( | ) | const |
Return the width of the image.
bool CL_Image::is_null | ( | ) | const [inline] |
Returns true if this object is invalid.
bool CL_Image::operator!= | ( | const CL_Image & | other | ) | const [inline] |
Inequality operator.
bool CL_Image::operator< | ( | const CL_Image & | other | ) | const [inline] |
Less than operator.
bool CL_Image::operator== | ( | const CL_Image & | other | ) | const [inline] |
Equality operator.
void CL_Image::set_alignment | ( | CL_Origin | origin, | |
int | x = 0 , |
|||
int | y = 0 | |||
) |
Sets translation hotspot.
void CL_Image::set_alpha | ( | float | alpha | ) |
Sets transparency.
Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).
void CL_Image::set_color | ( | const CL_Color & | c | ) | [inline] |
Set color.
c | = Color |
References CL_Colorf::a, CL_Colorf::b, CL_Colorf::g, CL_Color::get_alpha(), CL_Color::get_blue(), CL_Color::get_green(), CL_Color::get_red(), CL_Colorf::r, and set_color().
Referenced by set_color().
void CL_Image::set_color | ( | const CL_Colorf & | color | ) |
Sets the color.
Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).
void CL_Image::set_linear_filter | ( | bool | linear_filter = true |
) |
Set to true if a linear filter should be used for scaling up and down, false if a nearest-point filter should be used.
void CL_Image::set_scale | ( | float | x, | |
float | y | |||
) |
Set scale for x and y directions individually.
1.0f is normal scale, 2.0f is twice the size, etc.
void CL_Image::set_subimage | ( | int | x, | |
int | y, | |||
const CL_PixelBuffer & | image, | |||
const CL_Rect & | src_rect, | |||
int | level = 0 | |||
) |
Upload image to sub texture.
image | Image to upload. | |
level | Mipmap level-of-detail number. |
void CL_Image::set_wrap_mode | ( | CL_TextureWrapMode | wrap_s, | |
CL_TextureWrapMode | wrap_t | |||
) |
void CL_Image::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.