Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZImage Class Reference

#include <ZE_ZImage.h>

Inherits ZE::ZObject.

List of all members.


Detailed Description

ZImage image drawing class, class wraps common features of SDL_Surface. Inherited from ZObject.


Public Methods

 ZImage ()
 Default Constructor.

 ZImage::ZImage (const ZImage &rhs)
 Copy constructor for ZImage.

 ZImage (string filename)
 Constructor to Construct from File.

 ZImage (SDL_Surface *surface)
 Constructor to Construct from SDL_Surface*.

 ZImage (SDL_Surface *img, Sint16 x, Sint16 y, Sint16 w, Sint16 h)
 Constructor to Construct from part of an SDL_Surface*.

 ~ZImage ()
 Destructor, frees memory.

void Open (string filename)
 Opens a file.

void OpenFromImage (SDL_Surface *img, Sint16 x, Sint16 y, Sint16 w, Sint16 h)
 Cuts part of an existing image to create the new image.

void Attach (SDL_Surface *surface)
 Attach an existing surface to class.

void Reload ()
 Reattach a preloaded texture that has been lost.

void Release ()
 Releases image.

void SetColorKey (Uint8 red, Uint8 green, Uint8 blue)
 Set Color Key (transparent color) of Image.

void Flip (bool horizontal, bool vertical)
 Flip image over one or both axes.

void Stretch (float xFactor, float yFactor)
 Stretch the image by a certain X and Y factor.

void Resize (unsigned int width, unsigned int height)
 Resizes an image, stretching to new size.

void Bind () const
 OpenGL related bind call.

void Draw (float x, float y) const
 Draw Image to Screen.

void DrawRotated (int x, int y, float angle) const
 Draw Image rotated to screen.

bool IsLoaded () const
 Check if file is loaded.

SDL_Surface * Surface () const
 Get SDL_Surface. Get SDL_Surface pointer to actual image data.

int Width () const
 Get Width.

int Height () const
 Get Height.


Protected Attributes

GLfloat rTexMinX
 Texture lower X, used internally for flip.

GLfloat rTexMinY
 Texture lower Y, used internally for flip.

GLfloat rTexMaxX
 Texture X width ratio, used internally by OpenGL.

GLfloat rTexMaxY
 Texture Y width ratio, used internally by OpenGL.

SDL_Surface * rImage
 Stored texture for future use.

unsigned int rTexID
 Texture ID for OpenGL.

unsigned int rWidth
 Current draw width of Texture.

unsigned int rHeight
 Current draw height of Texture.


Constructor & Destructor Documentation

ZE::ZImage::ZImage  
 

Default Constructor, initializes variables.

ZE::ZImage::ZImage string    filename
 

Constructor is same as calling ZImage::Open() on passed filename.

Parameters:
filename File to open as rImage.

ZE::ZImage::ZImage SDL_Surface *    surface
 

Constructor is same as calling ZImage::Attach() on passed SDL_Surface*.

Parameters:
surface SDL_Surface* to use as rImage.

ZE::ZImage::ZImage SDL_Surface *    img,
Sint16    x,
Sint16    y,
Sint16    w,
Sint16    h
 

Constructor is same as calling ZImage::OpenFromImage.

Parameters:
img Image to take new image from.
x X Coordinate in source of top left corner.
y Y Coordinate in source of top left corner.
w Width of new image.
h Height of new image.

ZE::ZImage::~ZImage  
 

Destructor calls ZImage::Release().


Member Function Documentation

ZE::ZImage::ZImage::ZImage const ZImage &    rhs
 

Creates one ZImage using another.

Parameters:
rhs A previously created ZImage to copy.

void ZE::ZImage::Open string    filename
 

Open a file using ZEngine. Loads into rImage member of class.

Parameters:
filename File to open as rImage.

void ZE::ZImage::OpenFromImage SDL_Surface *    img,
Sint16    x,
Sint16    y,
Sint16    w,
Sint16    h
 

Cut part of an SDL_Surface to create a new Image.

Parameters:
img Image to take new image from.
x X Coordinate in source of top left corner.
y Y Coordinate in source of top left corner.
w Width of new image.
h Height of new image.

void ZE::ZImage::Attach SDL_Surface *    surface
 

Attach a pointer to instance of ZImage. (NOTE: Should not be used on a surface that is owned elsewhere.)

Parameters:
surface SDL_Surface* to use as rImage.

void ZE::ZImage::Reload  
 

Attach loaded textures which have been lost due to loss of focus, should be called when ZEngine::ImagesNeedReload is true.

void ZE::ZImage::Release  
 

Frees memory via call to SDL_FreeSurface for the image.

void ZE::ZImage::SetColorKey Uint8    red,
Uint8    green,
Uint8    blue
 

Set color which will not be drawn in image.

Parameters:
red Red component of colorkey (0-255).
green Green component of colorkey (0-255).
blue Blue component of colorkey (0-255).

void ZE::ZImage::Flip bool    horizontal,
bool    vertical
 

Flip image vertical and/or horizontal.

Parameters:
horizontal Boolean, true will flip image horizontally.
vertical Boolean, true will flip image vertically.

void ZE::ZImage::Stretch float    xFactor,
float    yFactor
 

Stretch image using a factor to multiply width and height by.

Parameters:
xFactor Stretch factor for width. [newWidth = oldWidth * xStretch]
yFactor Stretch factor for height. [newHeight = oldHeight * yStretch]

void ZE::ZImage::Resize unsigned int    width,
unsigned int    height
 

Stretch image to new width and height.

Parameters:
width New width to stretch image to.
height New height to stretch image to.

void ZE::ZImage::Bind   const
 

OpenGL related bind call, only available in case you want to bind image in 3D. Draw uses this but the average user should never need to call this.

void ZE::ZImage::Draw float    x,
float    y
const
 

Draw Image to screen at specified location.

Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.

void ZE::ZImage::DrawRotated int    x,
int    y,
float    angle
const
 

Image is rotated about it's own center by specified angle, then drawn to screen.

Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
angle Angle in degrees to rotate image.

bool ZE::ZImage::IsLoaded   const
 

Check if surface is a valid GL texture. (does not detect surface loss)

Returns:
Loaded or Unloaded state of data.

SDL_Surface * ZE::ZImage::Surface   const
 

Returns:
SDL_Surface* of rImage.

int ZE::ZImage::Width   const
 

Get Current Width of Image.

Returns:
Image Width.

int ZE::ZImage::Height   const
 

Get Current Height of Image.

Returns:
Image Height.


The documentation for this class was generated from the following files:
Generated on Sat Jan 18 17:53:20 2003 for ZEngine by doxygen1.3-rc2