Main Page   Namespace List   Class Hierarchy   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 2d textures under OpenGL or SDL_Surface under SDL.


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 OpenFromZip (std::string zipname, std::string filename)
 Opens an image file from within a zip archive.

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 Draw (int x, int y) const
 Draw Image to Screen.

void DrawClipped (int x, int y, ZRect clipRect) const
 Draw Image, clipped within a given rectangle to the screen.

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

void Draw (float x, float y, Uint8 vc[]) const
 Draw Image to screen with shaded/colored vertices.

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

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

void DrawRotated (float x, float y, float angle, Uint8 vc[]) const
 Draw Image rotated to screen with shaded/colored vertices.

void DrawClipped (float x, float y, ZRect clipRect) const
 Draw Image, clipped within a given rectangle to the screen.

void DrawClipped (float x, float y, ZRect clipRect, Uint8 vc[]) const
 Draw Image, clipped within a given rectangle to the screen with colored/shaded vertices.

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 (float width, float height)
 Resizes an image, stretching to new size.

void Bind () const
 OpenGL related bind call.

bool IsLoaded () const
 Check if file is loaded.

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

float Width () const
 Get Width.

float Height () const
 Get Height.

Uint8 Alpha () const
 Get Alpha component.


Protected Attributes

ZEnginerEngine
 Pointer to ZEngine Object.

SDL_Surface * rImage
 Stored texture.

Uint8 rAlpha
 Stored alpha value for drawing texture.

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.

unsigned int rTexID
 Texture ID for OpenGL.

GLfloat rWidth
 Current draw width of Texture.

GLfloat rHeight
 Current draw height of 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 an image file using ZEngine.

Parameters:
filename File to open as new image.

void ZE::ZImage::OpenFromZip std::string  zipname,
std::string  filename
 

Open an image file from within a zip archive using zlib and SDL_RWops.

Parameters:
zipname Zip file to open image from.
filename File to open as new image.

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 for the image. (Called by destructor).

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::Draw int  x,
int  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::DrawClipped int  x,
int  y,
ZRect  clipRect
const
 

Image is drawn such that only portions of image which fall within a certain area appear. This clipping rectangle can be used for areas of the screen which are separated from others such as a splitscreen mode in a game or a map on a HUD.

Since:
0.8.5
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
clipRect Rectangle to clip within.

void ZE::ZImage::Draw float  x,
float  y
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.

void ZE::ZImage::Draw float  x,
float  y,
Uint8  vc[]
const
 

Draw Image to screen using OpenGL to shade and color vertices.

Since:
0.8.5
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
vc Uint8 vcolor[16] - Vertex colors for the four vertices. Arranged so that vcolor[0],vcolor[1],vcolor[2],vcolor[3] - R,G,B,A (respectively) of top left corner (after top-left corner goes around clockwise).

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.

void ZE::ZImage::DrawRotated float  x,
float  y,
float  angle
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.

void ZE::ZImage::DrawRotated float  x,
float  y,
float  angle,
Uint8  vc[]
const
 

Image is rotated about it's own center by specified angle, then drawn to screen with shaded or colored vertices.

Since:
0.8.5
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
angle Angle in degrees to rotate image.
vc Uint8 vcolor[16] - Vertex colors for the four vertices. Arranged so that vcolor[0],vcolor[1],vcolor[2],vcolor[3] - R,G,B,A (respectively) of top left corner (after top-left corner goes around clockwise).

void ZE::ZImage::DrawClipped float  x,
float  y,
ZRect  clipRect
const
 

Image is drawn such that only portions of image which fall within a certain area appear. This clipping rectangle can be used for areas of the screen which are separated from others such as a splitscreen mode in a game or a map on a HUD.

Since:
0.8.5
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
clipRect Rectangle to clip within.

void ZE::ZImage::DrawClipped float  x,
float  y,
ZRect  clipRect,
Uint8  vc[]
const
 

Image is drawn such that only portions of image which fall within a certain area appear. This clipping rectangle can be used for areas of the screen which are separated from others such as a splitscreen mode in a game or a map on a HUD. Image is drawn with colored/shaded vertices.

Since:
0.8.5
Parameters:
x X coord to draw Image to.
y Y coord to draw Image to.
clipRect Rectangle to clip within.
vc Uint8 vcolor[16] - Vertex colors for the four vertices. Arranged so that vcolor[0],vcolor[1],vcolor[2],vcolor[3] - R,G,B,A (respectively) of top left corner (after top-left corner goes around clockwise).

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 float  width,
float  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.

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.

float ZE::ZImage::Width  )  const
 

Get Current Width of Image.

Returns:
Image Width.

float 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 Oct 5 19:34:46 2003 for ZEngine by doxygen1.3