The Image resource class. More...
#include <Graphics/Image.h>
Inherits Resource<>.
Public Types | |
enum | DrawLocation { CENTER = 0, TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT } |
Defines the differant location to draw the image from. More... | |
Public Member Functions | |
virtual void | Destroy () |
Destroys the resource. | |
virtual uint | GetDataUsageInBytes () const |
Estimates the number of bytes used by the loaded image resource. | |
int | Width () const |
Gets the width in pixels of the currently loaded image. | |
int | Height () const |
Gets the height in pixels of the currently loaded image. | |
bool | HasAlpha () const |
Determines if the loaded image has an alpha channel. | |
void | Draw (float alpha=1.0f, DrawLocation loc=CENTER) const |
Draws the image. | |
void | DrawSubImage (const Rectf &r, float alpha=1.0f, DrawLocation loc=CENTER) const |
Draws a portion of the image. | |
uint | GetOpenGLID () const |
Returns the texture ID generated by opengl. | |
Static Public Attributes | |
static const std::string | ERROR_IMAGE_PATH = CreatePath("error.png") |
The Image resource class.
A resource type that is used for loading and drawing image files. The following image formats are supported:
enum Image::DrawLocation |
Defines the differant location to draw the image from.
void Image::Destroy | ( | ) | [virtual] |
Destroys the resource.
Deallocates all data allocated when the resource was loaded. Must be implemented by all classes that inherit from the Resource class but should never be called outside of the ResourceMgr class.
Implements Resource<>.
void Image::Draw | ( | float | alpha = 1.0f , |
|
DrawLocation | loc = CENTER | |||
) | const |
Draws the image.
[in] | alpha | the opacity to apply uniformly to the image. Defaults to 1 (fully opaque). |
[in] | loc | the location to draw the image. Defaults to CENTER. |
The image is drawn at the origin with the same width and height as the actual image. The DrawLocation is used to determine the place where the image is drawn at the origin. For example, CENTER draws the image center at the origin whereas TOPLEFT draws the image with the top left corner of the image at the origin.
void Image::DrawSubImage | ( | const Rectf & | r, | |
float | alpha = 1.0f , |
|||
DrawLocation | loc = CENTER | |||
) | const |
Draws a portion of the image.
[in] | r | the area of the image to draw. Will be clamped to the actual bounds of the image. The top left corner of the image is at (0,0) and the bottom right position is at (width,height). |
[in] | alpha | the opacity to apply uniformly to the image. Defaults to 1 (fully opaque). |
[in] | loc | the location to draw the image. Defaults to CENTER. |
The subimage is drawn at the origin with the same width and height as specified by r. The DrawLocation is used to determine the place where the image is drawn at the origin. For example, CENTER draws the image center at the origin whereas TOPLEFT draws the image with the top left corner of the image at the origin.
uint Image::GetOpenGLID | ( | ) | const [inline] |
Returns the texture ID generated by opengl.
bool Image::HasAlpha | ( | ) | const |
Determines if the loaded image has an alpha channel.
int Image::Height | ( | ) | const |
Gets the height in pixels of the currently loaded image.
int Image::Width | ( | ) | const |
Gets the width in pixels of the currently loaded image.
const std::string Image::ERROR_IMAGE_PATH = CreatePath("error.png") [static] |
< The path to an image that will always exist. Used when loading an image that does not exist.