CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Graphics


Modules

2D
3D

Compounds

class  csColorQuantizer
 Color quantizer. More...

struct  csRGBcolor
 An RGB color. More...

struct  csRGBpixel
 An RGB pixel. More...


Eye sensivity to different color components

Eye sensivity to different color components, from NTSC grayscale equation.

The coefficients are multiplied by 100 and rounded towards nearest integer, to facilitate integer math. The squared coefficients are also multiplied by 100 and rounded to nearest integer (thus 173 == 1.73, 242 == 2.42 etc).

#define R_COEF   173
 Red component sensivity.

#define G_COEF   242
 Green component sensivity.

#define B_COEF   107
 Blue component sensivity.


Eye sensivity to different color components, squared

#define R_COEF_SQ   299
 Red component sensivity, squared.

#define G_COEF_SQ   587
 Green component sensivity, squared.

#define B_COEF_SQ   114
 Blue component sensivity, squared.


Pixel packing

When using csRGBcolor or csRGBpixel, don't assume that sizeof(csRGBcolor) == 3, sizeof(csRGBpixel) == 4 or that those struct are stored as a packed RGB/RGBA byte array.

If you need such packed RGB/RGBA data (e.g. for use with external libraries) use the functions here to convert from csRGBcolor/csRGBpixel to RGB/RGBA and vice versa. If no copy of the data is needed, they are free on platforms where sizeof(csRGBcolor) == 3, sizeof(csRGBpixel) == 4 are true. In any other case copying/packing the data is handled appropriately.

uint8csPackRGBcolorToRGB (const csRGBcolor *pixels, int numPixels)
 Pack an array of csRGBcolor into a RGB byte array.

void csDiscardPackedRGB (const uint8 *rgb)
 Frees memory possibly allocated by csPackRGBcolorToRGB().

const csRGBcolorcsUnpackRGBtoRGBcolor (const uint8 *rgb, int numPixels)
 Unpack a RGB byte array into an array of csRGBcolor.

void csDiscardUnpackedRGBcolor (const csRGBcolor *pixels)
 Frees memory possibly allocated by csUnpackRGBtoRGBcolor().

const uint8csPackRGBpixelToRGBA (const csRGBpixel *pixels, int numPixels)
 Pack an array of csRGBpixel into a RGBA byte array.

void csDiscardPackedRGBA (const uint8 *rgba)
 Frees memory possibly allocated by csPackRGBpixelToRGBA().

const csRGBpixelcsUnpackRGBAtoRGBpixel (const uint8 *rgba, int numPixels)
 Unpack a RGBA byte array into an array of csRGBpixel.

csRGBpixelcsCopyUnpackRGBAtoRGBpixel (const uint8 *rgba, int numPixels)
 Unpack a RGBA byte array into an array of csRGBpixel.

void csDiscardUnpackedRGBpixel (const csRGBpixel *pixels)
 Frees memory possibly allocated by csUnpackRGBAtoRGBpixel().

uint8csPackRGBpixelToRGB (const csRGBpixel *pixels, int numPixels)
 Pack an array of csRGBpixel into a RGB byte array.

csRGBcolorcsUnpackRGBAtoRGBcolor (const uint8 *rgba, int numPixels)
 Unpack a RGBA byte array into an array of csRGBcolor.


Functions

csPtr< iImagecsCreateXORPatternImage (int width, int height, int recdepth, float red=1.0f, float green=1.0f, float blue=1.0f)
 Create an iImage with a nice XOR pattern with 2^recdepth shades of from white to black.


Define Documentation

#define B_COEF   107
 

Blue component sensivity.

Definition at line 202 of file rgbpixel.h.

#define B_COEF_SQ   114
 

Blue component sensivity, squared.

Definition at line 211 of file rgbpixel.h.

#define G_COEF   242
 

Green component sensivity.

Definition at line 200 of file rgbpixel.h.

#define G_COEF_SQ   587
 

Green component sensivity, squared.

Definition at line 209 of file rgbpixel.h.

#define R_COEF   173
 

Red component sensivity.

Definition at line 198 of file rgbpixel.h.

#define R_COEF_SQ   299
 

Red component sensivity, squared.

Definition at line 207 of file rgbpixel.h.


Function Documentation

csRGBpixel * csCopyUnpackRGBAtoRGBpixel const uint8   pixels,
int    numPixels
[inline]
 

Unpack a RGBA byte array into an array of csRGBpixel.

Remarks:
Never returns pixels. Allocate memory. Free it using delete[] when finished.
Parameters:
rgba  Source array of RGBA data
numPixels  Number of pixels in the array
Returns:
An array containing the source data in csRGBpixel structs.

Definition at line 252 of file packrgb.h.

References csUnpackRGBAtoRGBpixel().

csPtr<iImage> csCreateXORPatternImage int    width,
int    height,
int    recdepth,
float    red = 1.0f,
float    green = 1.0f,
float    blue = 1.0f
 

Create an iImage with a nice XOR pattern with 2^recdepth shades of from white to black.

Parameters:
width  Width of the image to create
height  Height of the image to create
recdepth  "recursion depth", clamped to range 1-8.
red  Maximum value of red component
green  Maximum value of green component
blue  Maximum value of blue component

void csDiscardPackedRGB const uint8   rgb [inline]
 

Frees memory possibly allocated by csPackRGBcolorToRGB().

Parameters:
rgb  Pointer to packed RGB data returned by csPackRGBcolorToRGB().

Definition at line 118 of file packrgb.h.

void csDiscardPackedRGBA const uint8   rgba [inline]
 

Frees memory possibly allocated by csPackRGBpixelToRGBA().

Parameters:
rgba  Pointer to packed RGB data returned by csPackRGBpixelToRGBA().

Definition at line 231 of file packrgb.h.

void csDiscardUnpackedRGBcolor const csRGBcolor   pixels [inline]
 

Frees memory possibly allocated by csUnpackRGBtoRGBcolor().

Parameters:
pixels  Pointer to csRGBcolor array returned by csUnpackRGBtoRGBcolor().

Definition at line 138 of file packrgb.h.

void csDiscardUnpackedRGBpixel const csRGBpixel   pixels [inline]
 

Frees memory possibly allocated by csUnpackRGBAtoRGBpixel().

Parameters:
pixels  Pointer to csRGBpixel array returned by csUnpackRGBAtoRGBpixel().

Definition at line 258 of file packrgb.h.

const uint8 * csPackRGBcolorToRGB const csRGBcolor   pixels,
int    numPixels
[inline]
 

Pack an array of csRGBcolor into a RGB byte array.

Remarks:
May return pixels. May allocate memory. Free it using csDiscardPackedRGB() when finished.
Parameters:
pixels  Source array of csRGBcolor data
numPixels  Number of pixels in the array
Returns:
A byte array containing the source data packed as RGB.

Definition at line 103 of file packrgb.h.

References csRGBcolor::blue, csRGBcolor::green, and csRGBcolor::red.

uint8* csPackRGBpixelToRGB const csRGBpixel   pixels,
int    numPixels
[inline]
 

Pack an array of csRGBpixel into a RGB byte array.

Alpha information is discarded!

Remarks:
Allocates memory. Free it using delete[] when finished.
Parameters:
pixels  Source array of csRGBpixel data
numPixels  Number of pixels in the array
Returns:
A byte array containing the source data packed as RGB.

Definition at line 274 of file packrgb.h.

References csRGBpixel::blue, csRGBpixel::green, and csRGBpixel::red.

const uint8 * csPackRGBpixelToRGBA const csRGBpixel   pixels,
int    numPixels
[inline]
 

Pack an array of csRGBpixel into a RGBA byte array.

Remarks:
May return pixels. May allocate memory. Free it using csDiscardPackedRGBA() when finished.
Parameters:
pixels  Source array of csRGBpixel data
numPixels  Number of pixels in the array
Returns:
A byte array containing the source data packed as RGBA.

Definition at line 215 of file packrgb.h.

References csRGBpixel::alpha, csRGBpixel::blue, csRGBpixel::green, and csRGBpixel::red.

csRGBcolor* csUnpackRGBAtoRGBcolor const uint8   rgba,
int    numPixels
[inline]
 

Unpack a RGBA byte array into an array of csRGBcolor.

Alpha information is discarded!

Remarks:
Allocates memory. Free it using delete[] when finished.
Parameters:
rgba  Source array of RGBA data
numPixels  Number of pixels in the array
Returns:
An array containing the source data in csRGBcolor structs.

Definition at line 298 of file packrgb.h.

References csRGBcolor::blue, csRGBcolor::green, and csRGBcolor::red.

const csRGBpixel * csUnpackRGBAtoRGBpixel const uint8   rgba,
int    numPixels
[inline]
 

Unpack a RGBA byte array into an array of csRGBpixel.

Remarks:
May return pixels. May allocate memory. Free it using csDiscardUnpackedRGBpixel() when finished.
Parameters:
rgba  Source array of RGBA data
numPixels  Number of pixels in the array
Returns:
An array containing the source data in csRGBpixel structs.

Definition at line 236 of file packrgb.h.

References csRGBpixel::alpha, csRGBpixel::blue, csRGBpixel::green, and csRGBpixel::red.

Referenced by csCopyUnpackRGBAtoRGBpixel().

const csRGBcolor * csUnpackRGBtoRGBcolor const uint8   rgb,
int    numPixels
[inline]
 

Unpack a RGB byte array into an array of csRGBcolor.

Remarks:
May return pixels. May allocate memory. Free it using csDiscardUnpackedRGBcolor() when finished.
Parameters:
rgb  Source array of RGB data
numPixels  Number of pixels in the array
Returns:
An array containing the source data in csRGBcolor structs.

Definition at line 123 of file packrgb.h.

References csRGBcolor::blue, csRGBcolor::green, and csRGBcolor::red.


Generated for Crystal Space by doxygen 1.2.18