Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZImage Class Reference

#include <ZE_ZImage.h>

List of all members.


Detailed Description

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


Public Member Functions

 ZImage ()
 Default Constructor.

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

 ZImage (std::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 (const ZImage &img, Sint16 x, Sint16 y, Sint16 w, Sint16 h)
 Constructor to Construct from part of another ZImage.

virtual ~ZImage ()
 Destructor, frees memory.

void Open (std::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 a new image.

void OpenFromImage (const ZImage &img, Sint16 x, Sint16 y, Sint16 w, Sint16 h)
 Cuts part of an existing ZImage to create a 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 SetAlpha (Uint8 alpha)
 Set alpha value (translucency) of 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 (int x, int y, Uint8 zIndex=0) const
 Draw Image to Screen.

void Draw (float x, float y, Uint8 zIndex=0) const
 Draw Image to Screen.

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

void DrawRotated (float x, float y, float angle, Uint8 zIndex=0) 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.

Uint8 Alpha () const
 Get Alpha component.


Protected Attributes

ZEnginerEngine
 Pointer to ZEngine Object.

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.

Uint8 rAlpha
 Stored alpha value for drawing texture.


Constructor & Destructor Documentation

ZE::ZImage::ZImage  ) 
 

Default Constructor, initializes variables.

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

Creates one ZImage using another.

Parameters:
rhs A previously created ZImage to copy.

ZE::ZImage::ZImage std::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 with an SDL_Surface*.

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 const ZImage &  img,
Sint16  x,
Sint16  y,
Sint16  w,
Sint16  h
 

Constructor is same as calling ZImage::OpenFromImage with a ZImage.

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  )  [virtual]
 

Destructor calls ZImage::Release().


Member Function Documentation

void ZE::ZImage::Open std::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 SDL_Surface* 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::OpenFromImage const ZImage &  img,
Sint16  x,
Sint16  y,
Sint16  w,
Sint16  h
 

Cut part of another ZImage to create a new Image.

Parameters:
img ZImage 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::SetAlpha Uint8  alpha  ) 
 

Set translucency value 0-255 (0 is transparent, 255 = opaque).

Since:
0.8.2
Parameters:
alpha Number 0-255 setting translucency for 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 int  x,
int  y,
Uint8  zIndex = 0
const
 

Draw Image to screen at specified location.

Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
zLayer Special parameter defining draw order of the image, defaults to 0 which means 'draw immediately.' (1-255 define order, lowest first.)

void ZE::ZImage::Draw float  x,
float  y,
Uint8  zIndex = 0
const
 

Draw Image to screen at specified location.

Since:
0.8.3
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
zLayer Special parameter defining draw order of the image, defaults to 0 which means 'draw immediately.'

void ZE::ZImage::DrawRotated int  x,
int  y,
float  angle,
Uint8  zIndex = 0
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.
zLayer Special parameter defining draw order of the image, defaults to 0 which means 'draw immediately.'

void ZE::ZImage::DrawRotated float  x,
float  y,
float  angle,
Uint8  zIndex = 0
const
 

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

Since:
0.8.3
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
angle Angle in degrees to rotate image.
zLayer Special parameter defining draw order of the image, defaults to 0 which means 'draw immediately.'

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.

Uint8 ZE::ZImage::Alpha  )  const
 

Get current alpha value of image.

Since:
0.8.2
Returns:
Image Alpha.


The documentation for this class was generated from the following files:
Generated on Sun Jun 29 14:13:51 2003 for ZEngine by doxygen1.3