Main Page   Class Hierarchy   Compound List   Compound Members  

CAImageManipulation Class Reference

Provides some functions fo manipulate images (CL_Surfaces). More...

#include <caimagemanipulation.h>

List of all members.


Public Members

 CAImageManipulation ()
Constructor.

 ~CAImageManipulation ()
Destructor.


Static Public Members

CL_Surface* rotate ( CL_Surface* surface, float angle, bool exact=true )
Returns a pointer to a new image, based on 'surface' but rotated by an angle of 'degrees' degrees. More...

CL_Surface* flip ( CL_Surface* surface, bool horizontal )
Returns a pointer to a new image, based on 'surface' but fliped horizontal or vertical. More...

CL_Surface* changeHSV ( CL_Surface* surface, int hue, int saturation, int value )
Returns a pointer to a new image, based on 'surface' but with changed hue. More...

void rgbToHsv ( int r, int g, int b, int *h, int *s, int *v )
Converts an RGB color to a HSV color.

void hsvToRgb ( int h, int s, int v, int *r, int *g, int *b )
Converts an HSV color to a RGB color.

void getExactColor ( unsigned char* data, int width, int height, float x, float y, int *r, int *g, int *b, int *a, bool exact=true )
Gets the 'exact' color of a position in the image. More...

int getCoordinateX ( int width, int pos )
Gets a x coordinate from a data position in a 4bpp image. More...

int getCoordinateY ( int width, int pos )
Gets a y coordinate from a data position in a 4bpp image. More...

int getDataPosition ( int width, int x, int y )
Gets the data position (index of unsigned char* array) from a given x/y coordinate
Parameters:
x - X-Coordinate
y - Y-Coordinate
width - Image width in pixels.


float getDistance ( float x1, float y1, float x2, float y2 )
Returns the distance from one point to an other.


Detailed Description

Provides some functions fo manipulate images (CL_Surfaces).

Author(s):
Andrew Mustun , Benjamin Winkler <bentsch@mail.com>

Member Function Documentation

CL_Surface * CAImageManipulation::rotate (CL_Surface * surface, float angle, bool exact = true) [static]

Returns a pointer to a new image, based on 'surface' but rotated by an angle of 'degrees' degrees.

Parameters:
surface - The original surface
angle - Rotation angle in degrees (clock-wise)
exact - true: Exact, smooth coloring (calculates color 'between' pixels) false: Inexact but faster.

CL_Surface * CAImageManipulation::flip (CL_Surface * surface, bool horizontal) [static]

Returns a pointer to a new image, based on 'surface' but fliped horizontal or vertical.

Parameters:
horizontal - true: Flip horizontal (left to right) false: Flip vertical (upsidedown)

CL_Surface * CAImageManipulation::changeHSV (CL_Surface * surface, int hue, int saturation, int value) [static]

Returns a pointer to a new image, based on 'surface' but with changed hue.

Changing the hue means to "rotate" the color spectrum. You can read more about the HSV color model on the Internet. This method is used to change the color of a sprite (e.g. a car or another object). I sudggest to make the basic images in a red color-spectrum and create all other colors from it. For examples, please visit the Trophy homepage developer corner (http://)

Parameters:
hue - Changing of hue: 0-360
saturation - Changing of saturation: -100...100
value - Changing of value (Color intensity): -100...100

void CAImageManipulation::getExactColor (unsigned char * data, int width, int height, float x, float y, int * r, int * g, int * b, int * a, bool exact = true) [static]

Gets the 'exact' color of a position in the image.

The position can be 'between' pixels. The color gets calculated as an intelligent mixture of the hit pixel and the pixels around.

Parameters:
data - Pointer to the image data (must be 4 bytes per pixel)
x - X-Position
y - Y-Position
width - Image width in pixels
height - Image height in pixels
r - The red color part gets written into this memory
g - The green color part gets written into this memory
b - The blue color part gets written into this memory
a - The alpha color part gets written into this memory
exact - true: Interpolate the color 'between' pixels false: No interpolation but faster.

int CAImageManipulation::getCoordinateX (int width, int pos) [static]

Gets a x coordinate from a data position in a 4bpp image.

Parameters:
pos - The position (index of unsigned char* array)
width - Image width in pixels

int CAImageManipulation::getCoordinateY (int width, int pos) [static]

Gets a y coordinate from a data position in a 4bpp image.

Parameters:
pos - The position (index of unsigned char* array)
width - Image width in pixels

The documentation for this class was generated from the following files:
Generated at Sat Aug 12 18:51:52 2000 by doxygen  written by Dimitri van Heesch, © 1997-1999