Image Class Reference

The Image resource class. More...

#include <Graphics/Image.h>

Inherits Resource<>.

List of all members.

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")

Detailed Description

The Image resource class.

A resource type that is used for loading and drawing image files. The following image formats are supported:

  1. PNG
  2. JPG
  3. TGA
  4. BMP
  5. DDS

Member Enumeration Documentation

Defines the differant location to draw the image from.

Enumerator:
CENTER 

The center of the image is drawn at the origin

TOPLEFT 

The top left corner of the image is drawn at the origin

TOPRIGHT 

The top right corner of the image is drawn at the origin

BOTTOMLEFT 

The bottom left corner of the image is drawn at the origin

BOTTOMRIGHT 

The bottom right corner of the image is drawn at the origin


Member Function Documentation

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.

Parameters:
[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.
See also:
DrawSubImage

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.

Parameters:
[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.
See also:
Draw

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.

Returns:
The opengl texture id for the image.
bool Image::HasAlpha (  )  const

Determines if the loaded image has an alpha channel.

Returns:
True if the loaded image has an alpha channel, false otherwise.
int Image::Height (  )  const

Gets the height in pixels of the currently loaded image.

Returns:
The height in pixels of the image.
int Image::Width (  )  const

Gets the width in pixels of the currently loaded image.

Returns:
The width in pixels of the image.

Member Data Documentation

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.


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:06 2010 for BrickOut |ReDuX| by  doxygen 1.6.3