clan::Image Class Reference - ClanLib SDK
Description: clan::Image Class Reference

Public Member Functions | Static Public Member Functions | List of all members
clan::Image Class Reference
clanDisplay 2D

Image class. More...

`#include <image.h>`

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

## Static Public Member Functions
static Image | load (Canvas &canvas, const std::string &id, const XMLResourceDocument &doc)
| Loads a Sprite from a XML resource definition.
static Resource< Image > | resource (Canvas &canvas, const std::string &id, const ResourceManager &resources)
| Retrieves a Sprite resource from the resource manager.

## Detailed Description

Image class.

## Constructor & Destructor Documentation

## ◆ Image() [1/6]

clan::Image::Image | ( |  | ) |

Constructs a null instance.

Referenced by clone(), load(), operator!=(), operator<(), and operator==().

## ◆ Image() [2/6]

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

## ◆ Image() [3/6]

clan::Image::Image | ( | Subtexture & | sub_texture | ) |

Constructs an image from a subtexture.

Parameters

  sub_texture | = Subtexture to get image data from

## ◆ Image() [4/6]

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

## ◆ Image() [5/6]

clan::Image::Image | ( | Canvas & | canvas,
|  | const std::string & | filename,
|  | const ImageImportDescription & | import_desc = ImageImportDescription() )

Constructs a Image.

Parameters

  canvas | = Canvas
  filename | Filename of image to load
  import_desc | = Image Import Description

## ◆ Image() [6/6]

clan::Image::Image | ( | Canvas & | canvas,
|  | const std::string & | filename,
|  | const FileSystem & | fs,
|  | const ImageImportDescription & | import_desc = ImageImportDescription() )

Constructs a Image.

Parameters

  canvas | = Canvas
  filename | Filename of image to load
  dir | = Virtual directory to load filename from
  import_desc | = Image Import Description

## ◆ ~Image()

virtual clan::Image::~Image | ( |  | ) |
| virtual

## Member Function Documentation

## ◆ clone()

Image clan::Image::clone | ( |  | ) | const

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

References Image().

## ◆ draw() [1/5]

void clan::Image::draw | ( | Canvas & | canvas,
|  | const Quadf & | dest ) const

Draw image on graphic context.

Parameters

  gc | Graphic context on which to render upon.
  dest | Quad to draw image in.

## ◆ draw() [2/5]

void clan::Image::draw | ( | Canvas & | canvas,
|  | const Rectf & | dest ) const

Draw image on graphic context.

Parameters

  gc | Graphic context on which to render upon.
  dest | Rectangle to draw image in.

## ◆ draw() [3/5]

void clan::Image::draw | ( | Canvas & | canvas,
|  | const Rectf & | src,
|  | const Quadf & | dest ) const

Draw image on graphic context.

Parameters

  gc | Graphic context on which to render upon.
  src | Source rectangle to draw. Use this is draw only part of the image.
  dest | Quad to draw image in.

## ◆ draw() [4/5]

void clan::Image::draw | ( | Canvas & | canvas,
|  | const Rectf & | src,
|  | const Rectf & | dest ) const

Draw image on graphic context.

Parameters

  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.

## ◆ draw() [5/5]

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

Draw image on graphic context.

Parameters

  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.

References clan::x, and clan::y.

## ◆ get_alignment()

void clan::Image::get_alignment | ( | Origin & | origin,
|  | float & | x,
|  | float & | y ) const

Returns translation hot-spot.

References clan::x, and clan::y.

## ◆ get_alpha()

float clan::Image::get_alpha | ( |  | ) | const

Returns current alpha.

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

## ◆ get_color()

Colorf clan::Image::get_color | ( |  | ) | const

Returns current color.

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

## ◆ get_height()

float clan::Image::get_height | ( |  | ) | const

Return the height of the image.

## ◆ get_scale_x()

float clan::Image::get_scale_x | ( |  | ) | const

Returns x scale.

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

## ◆ get_scale_y()

float clan::Image::get_scale_y | ( |  | ) | const

Returns y scale.

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

## ◆ get_size()

Sizef clan::Image::get_size | ( |  | ) | const

Return the size of the image.

## ◆ get_texture()

Subtexture clan::Image::get_texture | ( |  | ) | const

Return the texture of the image.

## ◆ get_width()

float clan::Image::get_width | ( |  | ) | const

Return the width of the image.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ load()

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

Loads a Sprite from a XML resource definition.

References Image().

## ◆ operator bool()

clan::Image::operator bool | ( |  | ) | const
| inlineexplicit

## ◆ operator!=()

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

Inequality operator.

References Image().

## ◆ operator<()

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

Less than operator.

References Image().

## ◆ operator==()

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

Equality operator.

References Image().

## ◆ resource()

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

## ◆ set_alignment()

void clan::Image::set_alignment | ( | Origin | origin,
|  | float | x = 0,
|  | float | y = 0 )

Sets translation hotspot.

References clan::x, and clan::y.

## ◆ set_alpha()

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

Sets transparency.

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

## ◆ set_color() [1/2]

void clan::Image::set_color | ( | const Color & | c | ) |
| inline

Set color.

Parameters

  c | = Color

References clan::c, clan::color, and set_color().

Referenced by set_color().

## ◆ set_color() [2/2]

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

Sets the color.

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

References clan::color.

## ◆ set_linear_filter()

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.

## ◆ set_scale()

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.

References clan::x, and clan::y.

## ◆ set_subimage()

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

  canvas | Canvas to use for the request.
  x | The horizontal point in the texture to write the new sub-texture image onto.
  y | The vertical point in the texture to write the new sub-texture image onto.
  image | Image to upload.
  level | Mipmap level-of-detail number.

References clan::image, clan::x, and clan::y.

## ◆ set_wrap_mode()

void clan::Image::set_wrap_mode | ( | TextureWrapMode | wrap_s,
|  | TextureWrapMode | wrap_t )

## ◆ throw_if_null()

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:

- image.h