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

WPCG::WP_Image Class Reference

#include <WP_Image.h>

List of all members.

Public Methods

 WP_Image ()
 WP_Image (int width, int height)
 WP_Image (const string &filename)
 WP_Image (const WP_Image &image)
 ~WP_Image ()
WP_Image & operator= (const WP_Image &image)
void setPixel (int x, int y, const WP_RGBA &p)
void setFastPixel (int x, int y, const WP_RGBA &p)
WP_RGBAgetPixel (int x, int y)
WP_RGBAgetFastPixel (int x, int y)
void drawToFrameBuffer () const
bool readFromFrameBuffer (int x, int y, int width, int height)
void copy (int x, int y, int width, int height)
void setTextureGL (GLuint *texture_id, GLint wrap_s=GL_REPEAT, GLint wrap_t=GL_REPEAT, GLint mag_filter=GL_NEAREST, GLint min_filter=GL_NEAREST, bool mipmapping=false)
bool loadImage (const string &file)
void chromaKey (const WP_RGBA &key, byte alpha)

Public Attributes

int rasterpos_x
int rasterpos_y
int rows
int columns

Protected Methods

bool hasValidExtension (const string &file, const string &extension)
bool loadBMP (const string &file)
bool loadPCX (const string &file)

Protected Attributes

WP_RGBApixels


Detailed Description

this class is mainly used for image loading and texture creation. Currently, compressed/uncompressed 8 bit (indexed) bmp and uncompressed 24 bit (RGB) bmp and compressed 24 (indexed) bit pcx and compressed 24 bit (RGB) pcx files are supported
. Note that the .bmp format is always in little endian format
Author:
Copyright (C) 2001 W.P. van Paassen peter@paassen.tmfweb.nl
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


Constructor & Destructor Documentation

WPCG::WP_Image::WP_Image  
 

WPCG::WP_Image::WP_Image int    width,
int    height
 

WPCG::WP_Image::WP_Image const string &    filename
 

WPCG::WP_Image::WP_Image const WP_Image &    image
 

WPCG::WP_Image::~WP_Image  
 


Member Function Documentation

void WPCG::WP_Image::chromaKey const WP_RGBA   key,
byte    alpha
 

this function is able to set the alpha of all pixels matching the key pixel (chroma keying or blue screening)

Parameters:
key  the to be matched pixel. Only the alpha value of pixels matching this key are set to alpha
alpha  the new alpha value of the matching pixel

void WPCG::WP_Image::copy int    x,
int    y,
int    width,
int    height
[inline]
 

this function copies a rectangular portion of the backbuffer (the lowerleft corner, indicated by x, y, width and height) to the backbuffer at the current raster position

Parameters:
x  the column index which indicates the left column of the image's rectangle
y  the row index which indicates the lower row of the image's rectangle
width  the width of the image's rectangle
height  the height of the image's rectangle @ return a boolean indicating the success or failure of this function

void WPCG::WP_Image::drawToFrameBuffer   const
 

this function draws the image directly to the framebuffer using OpenGL, placing the lower left corner of the pixmap at the current raster position (rasterpos_x and rasterpos_y)

WP_RGBA* WPCG::WP_Image::getFastPixel int    x,
int    y
[inline]
 

this functions gets a pixel from the image without checking the ranges

Parameters:
x  the column index of the wanted pixel
y  the row index of the wanted pixel
Returns:
a pointer to WP_RGBA object holding the pixels' RGBA values

WP_RGBA* WPCG::WP_Image::getPixel int    x,
int    y
[inline]
 

this functions gets a pixel from the image

Parameters:
x  the column index of the wanted pixel
y  the row index of the wanted pixel
Returns:
a pointer to WP_RGBA object holding the pixels' RGBA values

bool WPCG::WP_Image::hasValidExtension const string &    file,
const string &    extension
[inline, protected]
 

this function checks the extension of a file

Parameters:
file  the file name
extension  the extension which is checked
Returns:
a boolean indicating if the file has the extension

bool WPCG::WP_Image::loadBMP const string &    file [protected]
 

this function loads a bitmap (.bmp). Currently compressed/uncompressed 8 bit (indexed) and uncompressed 24 bit RGB bmp

Parameters:
file  the bitmap file
Returns:
a boolean indicating the succes or failure of this function

bool WPCG::WP_Image::loadImage const string &    file
 

this function loads an image

Parameters:
file  the name of the file containing the image
Returns:
a boolean indicating the succes or failure of this function

bool WPCG::WP_Image::loadPCX const string &    file [protected]
 

this function loads ZSoft pcx file format (.pcx). Currently compressed 24 bit indexed and compressed 24 bit RGB pcs

Parameters:
file  the pcx file
Returns:
a boolean indicating the succes or failure of this function

WP_Image & WPCG::WP_Image::operator= const WP_Image &    image
 

assignment operator

Parameters:
image  the to be copied WP_Image object
Returns:
a reference to this new object containing the new copied image values

bool WPCG::WP_Image::readFromFrameBuffer int    x,
int    y,
int    width,
int    height
 

this function reads an rectangular image from the lower leftcorner of the framebuffer and stores it in this image

Parameters:
x  the column index which indicates the left column of the image's rectangle
y  the row index which indicates the lower row of the image's rectangle
width  the width of the image's rectangle
height  the height of the image's rectangle @ return a boolean indicating the success or failure of this function

void WPCG::WP_Image::setFastPixel int    x,
int    y,
const WP_RGBA   p
[inline]
 

this function writes a pixel in the current image without checking the x and y ranges

Parameters:
x  the column index of the to be placed pixel
y  the row index of the to be placed pixel
p  a WP_RGBA object representing the pixel and holding the pixels' RGBA values

void WPCG::WP_Image::setPixel int    x,
int    y,
const WP_RGBA   p
[inline]
 

this function writes a pixel in the current image

Parameters:
x  the column index of the to be placed pixel
y  the row index of the to be placed pixel
p  a WP_RGBA object representing the pixel and holding the pixels' RGBA values

void WPCG::WP_Image::setTextureGL GLuint *    texture_id,
GLint    wrap_s = GL_REPEAT,
GLint    wrap_t = GL_REPEAT,
GLint    mag_filter = GL_NEAREST,
GLint    min_filter = GL_NEAREST,
bool    mipmapping = false
 

this function creates a texture from this image and sets it for the use in OpenGL

Parameters:
texture_id  a pointer to an unsigned integer in which the texture id is stored by OpenGL
wrap_s  specifies OpenGL's behaviour for wrapping a texture in the s direction (see OpenGL red book), default is GL_REPEAT
wrap_t  specifies OpenGL's behaviour for wrapping a texture in the t direction (see OpenGL red book), default is GL_REPEAT
mag_filter  specifies OpenGL's behaviour for magnifying and filtering the texture (see OpenGL red book), default is GL_NEAREST
min_filter  specifies OpenGL's behaviour for minifying and filtering the texture (see OpenGL red book), default is GL_NEAREST
mipmapping  a boolean indicating if mip maps of the textrure should be created ans used by OpenGL (see OpenGL red book), default is false


Member Data Documentation

int WPCG::WP_Image::columns
 

the number of pixel columns in the image

WP_RGBA* WPCG::WP_Image::pixels [protected]
 

the array of pixels

int WPCG::WP_Image::rasterpos_x
 

the x raster position of the image in the framebuffer

int WPCG::WP_Image::rasterpos_y
 

the y raster position of the image in the framebuffer

int WPCG::WP_Image::rows
 

the number of pixel rows in the image


The documentation for this class was generated from the following files:
Generated on Tue Jan 28 20:26:39 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002