Image class. More...

#include <image.h>

Public Member Functions

 Image ()
 Constructs a null instance. More...
 
 Image (Texture2D texture, const Rect &rect)
 Constructs an image from a texture. More...
 
 Image (Subtexture &sub_texture)
 Constructs an image from a subtexture. More...
 
 Image (Canvas &canvas, const PixelBuffer &pixelbuffer, const Rect &rect)
 Constructs a Image from a pixelbuffer. More...
 
 Image (Canvas &canvas, const std::string &filename, const ImageImportDescription &import_desc=ImageImportDescription())
 Constructs a Image. More...
 
 Image (Canvas &canvas, const std::string &filename, const FileSystem &fs, const ImageImportDescription &import_desc=ImageImportDescription())
 Constructs a Image. More...
 
virtual ~Image ()
 
Image clone () const
 Copies all information from this image to another, excluding the graphics that remain shared. More...
 
void draw (Canvas &canvas, float x, float y) const
 Draw image on graphic context. More...
 
void draw (Canvas &canvas, const Rectf &src, const Rectf &dest) const
 Draw image on graphic context. More...
 
void draw (Canvas &canvas, const Rectf &dest) const
 Draw image on graphic context. More...
 
void draw (Canvas &canvas, const Rectf &src, const Quadf &dest) const
 Draw image on graphic context. More...
 
void draw (Canvas &canvas, const Quadf &dest) const
 Draw image on graphic context. More...
 
void get_alignment (Origin &origin, float &x, float &y) const
 Returns translation hot-spot. More...
 
float get_alpha () const
 Returns current alpha. More...
 
Colorf get_color () const
 Returns current color. More...
 
float get_height () const
 Return the height of the image. More...
 
float get_scale_x () const
 Returns x scale. More...
 
float get_scale_y () const
 Returns y scale. More...
 
Sizef get_size () const
 Return the size of the image. More...
 
Subtexture get_texture () const
 Return the texture of the image. More...
 
float get_width () const
 Return the width of the image. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
 operator bool () const
 
bool operator!= (const Image &other) const
 Inequality operator. More...
 
bool operator< (const Image &other) const
 Less than operator. More...
 
bool operator== (const Image &other) const
 Equality operator. More...
 
void set_alignment (Origin origin, float x=0, float y=0)
 Sets translation hotspot. More...
 
void set_alpha (float alpha)
 Sets transparency. More...
 
void set_color (const Colorf &color)
 Sets the color. More...
 
void set_color (const Color &c)
 Set color. More...
 
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. More...
 
void set_scale (float x, float y)
 Set scale for x and y directions individually. More...
 
void set_subimage (Canvas &canvas, int x, int y, const PixelBuffer &image, const Rect &src_rect, int level=0)
 
void set_wrap_mode (TextureWrapMode wrap_s, TextureWrapMode wrap_t)
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Static Public Member Functions

static Image load (Canvas &canvas, const std::string &id, const XMLResourceDocument &doc)
 Loads a Sprite from a XML resource definition. More...
 
static Resource< Imageresource (Canvas &canvas, const std::string &id, const ResourceManager &resources)
 Retrieves a Sprite resource from the resource manager. More...
 

Detailed Description

Image class.

Constructor & Destructor Documentation

clan::Image::Image ( )

Constructs a null instance.

clan::Image::Image ( Texture2D  texture,
const Rect rect 
)

Constructs an image from a texture.

Parameters
texture= Texture to get image data from
rect= Position and size in texture to get image data from
clan::Image::Image ( Subtexture sub_texture)

Constructs an image from a subtexture.

Parameters
sub_texture= Subtexture to get image data from
clan::Image::Image ( Canvas canvas,
const PixelBuffer pixelbuffer,
const Rect rect 
)

Constructs a Image from a pixelbuffer.

Parameters
canvas= Canvas
pixelbuffer= Pixelbuffer to get image data from
rect= pixelbuffer rect
clan::Image::Image ( Canvas canvas,
const std::string filename,
const ImageImportDescription import_desc = ImageImportDescription() 
)

Constructs a Image.

Parameters
canvas= Canvas
filenameFilename of image to load
import_desc= Image Import Description
clan::Image::Image ( Canvas canvas,
const std::string filename,
const FileSystem fs,
const ImageImportDescription import_desc = ImageImportDescription() 
)

Constructs a Image.

Parameters
canvas= Canvas
filenameFilename of image to load
dir= Virtual directory to load filename from
import_desc= Image Import Description
virtual clan::Image::~Image ( )
virtual

Member Function Documentation

Image clan::Image::clone ( ) const

Copies all information from this image to another, excluding the graphics that remain shared.

void clan::Image::draw ( Canvas canvas,
float  x,
float  y 
) const

Draw image on graphic context.

Parameters
x,yAnchor position of where to render image. Actual rendering position depends on the anchor and the alignment mode.
gcGraphic context on which to render upon.
void clan::Image::draw ( Canvas canvas,
const Rectf src,
const Rectf dest 
) const

Draw image on graphic context.

Parameters
gcGraphic context on which to render upon.
srcSource rectangle to draw. Use this is draw only part of the image.
destRectangle to draw image in.
void clan::Image::draw ( Canvas canvas,
const Rectf dest 
) const

Draw image on graphic context.

Parameters
gcGraphic context on which to render upon.
destRectangle to draw image in.
void clan::Image::draw ( Canvas canvas,
const Rectf src,
const Quadf dest 
) const

Draw image on graphic context.

Parameters
gcGraphic context on which to render upon.
srcSource rectangle to draw. Use this is draw only part of the image.
destQuad to draw image in.
void clan::Image::draw ( Canvas canvas,
const Quadf dest 
) const

Draw image on graphic context.

Parameters
gcGraphic context on which to render upon.
destQuad to draw image in.
void clan::Image::get_alignment ( Origin origin,
float &  x,
float &  y 
) const

Returns translation hot-spot.

float clan::Image::get_alpha ( ) const

Returns current alpha.

Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).

Colorf clan::Image::get_color ( ) const

Returns current color.

Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).

float clan::Image::get_height ( ) const

Return the height of the image.

float clan::Image::get_scale_x ( ) const

Returns x scale.

1.0f is normal scale, 2.0f is twice the size, etc.

float clan::Image::get_scale_y ( ) const

Returns y scale.

1.0f is normal scale, 2.0f is twice the size, etc.

Sizef clan::Image::get_size ( ) const

Return the size of the image.

Subtexture clan::Image::get_texture ( ) const

Return the texture of the image.

float clan::Image::get_width ( ) const

Return the width of the image.

bool clan::Image::is_null ( ) const
inline

Returns true if this object is invalid.

static Image clan::Image::load ( Canvas canvas,
const std::string id,
const XMLResourceDocument doc 
)
static

Loads a Sprite from a XML resource definition.

clan::Image::operator bool ( ) const
inlineexplicit
bool clan::Image::operator!= ( const Image other) const
inline

Inequality operator.

bool clan::Image::operator< ( const Image other) const
inline

Less than operator.

bool clan::Image::operator== ( const Image other) const
inline

Equality operator.

static Resource<Image> clan::Image::resource ( Canvas canvas,
const std::string id,
const ResourceManager resources 
)
static

Retrieves a Sprite resource from the resource manager.

Parameters
canvas= Canvas
resources= Resource manager
id= id
void clan::Image::set_alignment ( Origin  origin,
float  x = 0,
float  y = 0 
)

Sets translation hotspot.

void clan::Image::set_alpha ( float  alpha)

Sets transparency.

Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).

void clan::Image::set_color ( const Colorf color)

Sets the color.

Alpha 0.0f is full transparency, and 1.0f is full visibility (solid).

void clan::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 clan::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 clan::Image::set_subimage ( Canvas canvas,
int  x,
int  y,
const PixelBuffer image,
const Rect src_rect,
int  level = 0 
)

Upload image to sub-texture.

Parameters
canvasCanvas to use for the request.
xThe horizontal point in the texture to write the new sub-texture image onto.
yThe vertical point in the texture to write the new sub-texture image onto.
imageImage to upload.
levelMipmap level-of-detail number.
void clan::Image::set_wrap_mode ( TextureWrapMode  wrap_s,
TextureWrapMode  wrap_t 
)
void clan::Image::throw_if_null ( ) const

Throw an exception if this object is invalid.


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