CRM32Pro SDK  v5.22
List of all members | Public Member Functions

IPrimitives. More...

Detailed Description

IPrimitives.

Primitives interface system.

Public Member Functions

void BoxColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color)
 Draw a filled rectangle. More...
 
void BoxRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Draw a filled rectangle. More...
 
void CMYKtoRGB (unsigned char c, unsigned char m, unsigned char y, unsigned char k, unsigned char *r8, unsigned char *g8, unsigned char *b8)
 Color conversion: from CMYK to RGB. More...
 
void Get16Pixel (SDL_Surface *surf, short x, short y, unsigned int *arraypixels, unsigned char alock=1)
 Get a packed of 16 pixels. It only works with 32bit modes. More...
 
int GetCollisionMethod ()
 Get current collision detection method. More...
 
unsigned int GetPixel (SDL_Surface *surf, short x, short y, unsigned char alock=1)
 Get a single pixel. More...
 
void HLineColor (SDL_Surface *surf, short x1, short x2, short y, unsigned int color)
 Draw a horinzontal line with bounce checking. More...
 
void HLineRGBA (SDL_Surface *surf, short x1, short x2, short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Draw a horinzontal line with bounce checking. More...
 
void HSVtoRGB (float h, float s, float v, unsigned char *r8, unsigned char *g8, unsigned char *b8)
 Color conversion: from HSV to RGB. More...
 
void LineColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color)
 Draw a line with bounce checking. More...
 
void LineRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Draw a line with bounce checking. More...
 
unsigned char PixelCollision (SDL_Surface *s1, SDL_Rect *r1, SDL_Surface *s, SDL_Rect *r2, unsigned char debug=0, SDL_Rect *posr1=NULL, SDL_Rect *posr2=NULL)
 Customizable collision detection between two surfaces. More...
 
void Put16Pixel (SDL_Surface *surf, short x, short y, unsigned int *arraypixels, unsigned char alock=1)
 Draw a pack of 16 pixels. It only works with 32bit modes. More...
 
void PutPixelColor (SDL_Surface *surf, short x, short y, unsigned int color, unsigned char alock=1)
 Draw a single pixel with bounce checking. More...
 
void PutPixelRGBA (SDL_Surface *surf, short x, short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255, unsigned char alock=1)
 Draw a single pixel with bounce checking. More...
 
void RectangleColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color)
 Draw an outlined rectangle. More...
 
void RectangleRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Draw an outlined rectangle. More...
 
void RGBtoCMYK (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *c, unsigned char *m, unsigned char *y, unsigned char *k)
 Color conversion: from RGB to CMYK. More...
 
void RGBtoHSV (unsigned char r8, unsigned char g8, unsigned char b8, float *h, float *s, float *v)
 Color conversion: from RGB to HSV. More...
 
void RGBtoYCC (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *Y, unsigned char *Cb, unsigned char *Cr)
 Color conversion: from RGB to YCC. More...
 
void RGBtoYUV (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *Y, unsigned char *U, unsigned char *V)
 Color conversion: from RGB to YUV. More...
 
void SetCollisionMethod (int mode)
 Set the collision detection method. More...
 
void VLineColor (SDL_Surface *surf, short x, short y1, short y2, unsigned int color)
 Draw a vertical line with bounce checking. More...
 
void VLineRGBA (SDL_Surface *surf, short x, short y1, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 Draw a vertical line with bounce checking. More...
 
void YCCtoRGB (unsigned char Y, unsigned char Cb, unsigned char Cr, unsigned char *r8, unsigned char *g8, unsigned char *b8)
 Color conversion: from YCC to RGB. More...
 
void YUVtoRGB (unsigned char Y, unsigned char U, unsigned char V, unsigned char *r8, unsigned char *g8, unsigned char *b8)
 Color conversion: from YUV to RGB. More...
 

Member Function Documentation

void CRM32Pro_IPrimitives::BoxColor ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned int  color 
)

Draw a filled rectangle.

Tests the clipping region and has support for cursor autorestore.

Parameters
surfsurface to render the rectangle
x1Desired start x position
y1Desired start y
x2Desired end x position
y2Desired end y
colorPacket(RGBA) pixel color
void CRM32Pro_IPrimitives::BoxRGBA ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Draw a filled rectangle.

Tests the clipping region and has support for cursor autorestore.

Parameters
surfsurface to render the rectangle
x1Desired start x position
y1Desired start y
x2Desired end x position
y2Desired end y
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
void CRM32Pro_IPrimitives::CMYKtoRGB ( unsigned char  c,
unsigned char  m,
unsigned char  y,
unsigned char  k,
unsigned char *  r8,
unsigned char *  g8,
unsigned char *  b8 
)

Color conversion: from CMYK to RGB.

Parameters
ccyan component
mmagenta component
yyellow component
kkey(black) component
r8pointer to Red component
g8pointer to Green component
b8pointer to Blue component
void CRM32Pro_IPrimitives::Get16Pixel ( SDL_Surface *  surf,
short  x,
short  y,
unsigned int *  arraypixels,
unsigned char  alock = 1 
)

Get a packed of 16 pixels. It only works with 32bit modes.

If you will access to the pixels surface to get the value of several pixels, you have to use alock=0 and
manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
If the given surface is an OpenGL texture (glSDL mode), it does nothing.

Parameters
surfsurface to get the pixel
xx position on surface
yy position on surface
arraypixelspixel color array (packed integer with RGB)
alockby default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface.
int CRM32Pro_IPrimitives::GetCollisionMethod ( )

Get current collision detection method.

Returns
Current collision detection method
unsigned int CRM32Pro_IPrimitives::GetPixel ( SDL_Surface *  surf,
short  x,
short  y,
unsigned char  alock = 1 
)

Get a single pixel.

If you will access to a few pixels, the best way is to manually manage the lock calling to Lock() and UnLock() and using alock=0
With OpenGL modes (glSDL), it works but when surf is not CRM32Pro.screen, it will be slower as it has to download the texture to the system memory.

Parameters
surfsurface to get the pixel
xx position on surface
yy position on surface
alockby default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface.
Returns
color pixel color (packed integer with RGB).
void CRM32Pro_IPrimitives::HLineColor ( SDL_Surface *  surf,
short  x1,
short  x2,
short  y,
unsigned int  color 
)

Draw a horinzontal line with bounce checking.

Tests the clipping region.

Parameters
surfsurface to render the line
x1Desired start x position
x2Desired end y position
yDesired y position
colorPacket(RGBA) pixel color
void CRM32Pro_IPrimitives::HLineRGBA ( SDL_Surface *  surf,
short  x1,
short  x2,
short  y,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Draw a horinzontal line with bounce checking.

Tests the clipping region.

Parameters
surfsurface to render the line
x1Desired start x position
x2Desired end y position
yDesired y position
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
void CRM32Pro_IPrimitives::HSVtoRGB ( float  h,
float  s,
float  v,
unsigned char *  r8,
unsigned char *  g8,
unsigned char *  b8 
)

Color conversion: from HSV to RGB.

Parameters
hHue component
sSaturation component
vValue component
r8pointer to Red component
g8pointer to Green component
b8pointer to Blue component
void CRM32Pro_IPrimitives::LineColor ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned int  color 
)

Draw a line with bounce checking.

Tests the clipping region.
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen

Parameters
surfsurface to render the line
x1Desired start x position
y1Desired start y position
x2Desired end x position
y2Desired end y position
colorPacket(RGBA) pixel color
void CRM32Pro_IPrimitives::LineRGBA ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Draw a line with bounce checking.

Tests the clipping region.
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen

Parameters
surfsurface to render the line
x1Desired start x position
y1Desired start y position
x2Desired end x position
y2Desired end y position
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
unsigned char CRM32Pro_IPrimitives::PixelCollision ( SDL_Surface *  surf1,
SDL_Rect *  pos1,
SDL_Surface *  surf2,
SDL_Rect *  pos2,
unsigned char  debug = 0,
SDL_Rect *  posr1 = NULL,
SDL_Rect *  posr2 = NULL 
)

Customizable collision detection between two surfaces.

You can modify the behaviour of the collision detection system using SetCollisionMethod(). First one, it tests a bounding box(BB) collision, if a collision of BB occurs, it will check for perfect pixel collision.
It could be slow if you are testing a lot of collisions. The advice is to use as less "external" colorkey around your sprite as possible to avoid to do a lot of pixel checking.

Parameters
surf1surface A
pos1rect with absolute position(x,y) and size(w,h) of surface A
surf2surface B to test collision against surface A
pos2rect with absolute (x,y) position and size of surface B
debugby default is 0 and it won't to render any debug information. Otherwise, will show collision bounding boxes.
posr1NULL(by default) or a rect pointer with relative position(x,y) inside the surface A.
posr2NULL(by default) or a rect pointer with relative position(x,y) inside the surface B.
Returns
0 There was not a surface collision
1 There was a surface collision
void CRM32Pro_IPrimitives::Put16Pixel ( SDL_Surface *  surf,
short  x,
short  y,
unsigned int *  arraypixels,
unsigned char  alock = 1 
)

Draw a pack of 16 pixels. It only works with 32bit modes.

Only supports 32bit depth color.
Also, it doesn't test the clipping region.
If you will access to the pixels surface to set the value of several pixels, you have to use alock=0 and
manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
If the given surface is an OpenGL texture (glSDL mode), it does nothing.

Parameters
surfsurface to dump the pixel
xx position on surface
yy position on surface
arraypixelspixel color array (packed integer with RGB)
alockby default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface.
void CRM32Pro_IPrimitives::PutPixelColor ( SDL_Surface *  surf,
short  x,
short  y,
unsigned int  color,
unsigned char  alock = 1 
)

Draw a single pixel with bounce checking.

Tests the clipping region.
If you will access to the pixels surface to set the value of several pixels, you may want to use alock=0 and manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen

Parameters
surfsurface to render the pixel
xDesired x position
yDesired y position
colorPacket(RGBA) pixel color
alock1 to lock the surface. Other value, don't lock the surface. By default is 1.
void CRM32Pro_IPrimitives::PutPixelRGBA ( SDL_Surface *  surf,
short  x,
short  y,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255,
unsigned char  alock = 1 
)

Draw a single pixel with bounce checking.

Tests the clipping region.
If you will access to the pixels surface to set the value of several pixels, you may want to use alock=0 and manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen

Parameters
surfsurface to render the pixel
xDesired x position
yDesired y position
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
alock1 to lock the surface. Other value, don't lock the surface. By default is 1.
void CRM32Pro_IPrimitives::RectangleColor ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned int  color 
)

Draw an outlined rectangle.

Tests the clipping region and has support for cursor autorestore.

Parameters
surfsurface to render the rectangle
x1Desired start x position
y1Desired start y
x2Desired end x position
y2Desired end y
colorPacket(RGBA) pixel color
void CRM32Pro_IPrimitives::RectangleRGBA ( SDL_Surface *  surf,
short  x1,
short  y1,
short  x2,
short  y2,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Draw an outlined rectangle.

Tests the clipping region and has support for cursor autorestore.

Parameters
surfsurface to render the rectangle
x1Desired start x position
y1Desired start y
x2Desired end x position
y2Desired end y
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
void CRM32Pro_IPrimitives::RGBtoCMYK ( unsigned char  r8,
unsigned char  g8,
unsigned char  b8,
unsigned char *  c,
unsigned char *  m,
unsigned char *  y,
unsigned char *  k 
)

Color conversion: from RGB to CMYK.

Parameters
r8Red component
g8Green component
b8Blue component
cpointer to cyan component
mpointer to magenta component
ypointer to yellow component
kpointer to key(black) component
void CRM32Pro_IPrimitives::RGBtoHSV ( unsigned char  r8,
unsigned char  g8,
unsigned char  b8,
float *  h,
float *  s,
float *  v 
)

Color conversion: from RGB to HSV.

Parameters
r8Red component
g8Green component
b8Blue component
hpointer to Hue component
spointer to Saturation component
vpointer to Value component
void CRM32Pro_IPrimitives::RGBtoYCC ( unsigned char  r8,
unsigned char  g8,
unsigned char  b8,
unsigned char *  Y,
unsigned char *  Cb,
unsigned char *  Cr 
)

Color conversion: from RGB to YCC.

Parameters
r8Red component
g8Green component
b8Blue component
Ypointer to luma component
Cbpointer to chrominance blue component
Crpointer to chrominance red component
void CRM32Pro_IPrimitives::RGBtoYUV ( unsigned char  r8,
unsigned char  g8,
unsigned char  b8,
unsigned char *  Y,
unsigned char *  U,
unsigned char *  V 
)

Color conversion: from RGB to YUV.

Parameters
r8Red component
g8Green component
b8Blue component
Ypointer to luma component
Upointer to chrominance U component
Vpointer to chrominance V component
void CRM32Pro_IPrimitives::SetCollisionMethod ( int  mode)

Set the collision detection method.

You can adjust the kind of accuracy Vs speed of the whole collision detection system.
By default, the mode is set to 1 for a perfect pixel collision.

Parameters
mode0 to set a very fast boundingbox(less acurrate but extremely fast)
1 to set a perfect pixel collision(100% accurate but the slowest method)
2, 3, 4, .. to set the collision detection check each 2, 3, 4, ... pixels.
void CRM32Pro_IPrimitives::VLineColor ( SDL_Surface *  surf,
short  x,
short  y1,
short  y2,
unsigned int  color 
)

Draw a vertical line with bounce checking.

Tests the clipping region.

Parameters
surfsurface to render the line
xDesired x position
y1Desired start y position
y2Desired end y position
colorPacket(RGBA) pixel color
void CRM32Pro_IPrimitives::VLineRGBA ( SDL_Surface *  surf,
short  x,
short  y1,
short  y2,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Draw a vertical line with bounce checking.

Tests the clipping region.

Parameters
surfsurface to render the line
xDesired x position
y1Desired start y position
y2Desired end y position
rRed component
gGreen component
bBlue component
aAlpha component. By default is 255.
void CRM32Pro_IPrimitives::YCCtoRGB ( unsigned char  Y,
unsigned char  Cb,
unsigned char  Cr,
unsigned char *  r8,
unsigned char *  g8,
unsigned char *  b8 
)

Color conversion: from YCC to RGB.

Parameters
Yluma component
Cbchrominance blue component
Crchrominance red component
r8pointer to Red component
g8pointer to Green component
b8pointer to Blue component
void CRM32Pro_IPrimitives::YUVtoRGB ( unsigned char  Y,
unsigned char  U,
unsigned char  V,
unsigned char *  r8,
unsigned char *  g8,
unsigned char *  b8 
)

Color conversion: from YUV to RGB.

Parameters
Yluma component
Uchrominance U component
Vchrominance V component
r8pointer to Red component
g8pointer to Green component
b8pointer to Blue component

The documentation for this class was generated from the following files: