#include <caimagemanipulation.h>
Public Member Functions | |
| CAImageManipulation () | |
| Constructor. | |
| ~CAImageManipulation () | |
| Destructor. | |
Static Public Member Functions | |
| static CL_Surface * | rotate (CL_Surface *surface, float angle, bool exact=true, bool green=true) |
| Returns a pointer to a new image, based on 'surface' but rotated by an angle of 'degrees' degrees. | |
| static CL_Surface * | flip (CL_Surface *surface, bool horizontal) |
| Returns a pointer to a new image, based on 'surface' but fliped horizontal or vertical. | |
| static 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. | |
| static void | clearCanvas (CL_Canvas *canvas) |
| Clears a canvas to transparent. | |
| static void | greenToTransparent (CL_Canvas *canvas) |
| Uses the green channel as transparency. | |
| static void | rgbToHsv (int r, int g, int b, int *h, int *s, int *v) |
| Converts an RGB color to a HSV color. | |
| static void | hsvToRgb (int h, int s, int v, int *r, int *g, int *b) |
| Converts an HSV color to a RGB color. | |
| static 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. | |
| static int | getCoordinateX (int width, int pos) |
| Gets a x coordinate from a data position in a 4bpp image. | |
| static int | getCoordinateY (int width, int pos) |
| Gets a y coordinate from a data position in a 4bpp image. | |
| static int | getDataPosition (int width, int x, int y) |
| Gets the data position (index of unsigned char* array) from a given x/y coordinate. | |
| static float | getDistance (float x1, float y1, float x2, float y2) |
| Returns the distance from one point to an other. | |
| CL_Surface * CAImageManipulation::rotate | ( | CL_Surface * | surface, | |
| float | angle, | |||
| bool | exact = true, |
|||
| bool | green = true | |||
| ) | [static] |
Returns a pointer to a new image, based on 'surface' but rotated by an angle of 'degrees' degrees.
| surface | The original surface | |
| angle | Rotation angle in degrees (clock-wise) | |
| exact | true: Exact, smooth coloring (calculates color 'between' pixels) false: Inexact but faster. | |
| green | Use green channel for transparency (Due to ClanLib bug in 0.5) |
| 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.
| 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://trophy.sourceforge.net)
| hue | Changing of hue: 0-360 | |
| saturation | Changing of saturation: -100...100 | |
| value | Changing of value (Color intensity): -100...100 |
| void CAImageManipulation::greenToTransparent | ( | CL_Canvas * | canvas | ) | [static] |
Uses the green channel as transparency.
Due to a bug with transparency introduced with ClanLib 0.5
| 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.
| 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.
| 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.
| pos | The position (index of unsigned char* array) | |
| width | Image width in pixels |
| int CAImageManipulation::getDataPosition | ( | int | width, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Gets the data position (index of unsigned char* array) from a given x/y coordinate.
| x | X-Coordinate | |
| y | Y-Coordinate | |
| width | Image width in pixels |
1.5.0