Client Library - Graphics API


Detailed Description

these are simple low-level graphics api functions, for further information you may look in demo, and the server source codes.

Example:
 // simple example code will be in here


Functions

int s_rgbcolor (s_surface_t *surface, int r, int g, int b)
 returns pixel value used in the current surface that corresponds with the given color components.
void s_colorrgb (s_surface_t *surface, int c, int *r, int *g, int *b)
 return the red, green, and blue values for the given color
void s_setpixel (s_surface_t *surface, int x, int y, int c)
 puts one pixel color to the x, y coordinate on the surface
void s_setpixelrgb (s_surface_t *surface, int x, int y, int r, int g, int b)
 puts one pixel color to the x, y coordinate on the surface
void s_setpixelrgba (s_surface_t *surface, int x, int y, int r, int g, int b, int a)
 puts one pixel color to the x, y coordinate on the surface (with alpha)
int s_getpixel (s_surface_t *surface, int x, int y)
 gets the color value of the pixel form x, y coordinates of the surface
void s_getpixelrgb (s_surface_t *surface, int x, int y, int *r, int *g, int *b)
 gets the red, green, blue values of the pixel form x, y coordinates of the surface
void s_hline (s_surface_t *surface, int x1, int y, int x2, int c)
 draw a horizontal line from point (x1, y) to (x2, y) in color c on to the surface
void s_vline (s_surface_t *surface, int x, int y1, int y2, int c)
 draw a vertical line from point (x, y1) to (x, y2) in color c on to the surface
void s_line (s_surface_t *surface, int x1, int y1, int x2, int y2, int c)
 draw a line from point (x1, y1) to (x2, y2) inclusively in color c
void s_fillbox (s_surface_t *surface, int x, int y, int w, int h, int c)
 fill a rectangular area at position (x, y) with size (w, h) of the screen with a single color c on to the surface
void s_putbox (s_surface_t *surface, int x, int y, int w, int h, void *sp)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxmask (s_surface_t *surface, int x, int y, int w, int h, char *sp, unsigned char *sm)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxalpha (s_surface_t *surface, int x, int y, int w, int h, char *sp, unsigned char *sm)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxrgba (s_surface_t *surface, int x, int y, int w, int h, unsigned int *rgba)
 copy the contents of a rgba buffer rgba to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxrgb (s_surface_t *surface, int x, int y, int w, int h, unsigned int *rgb)
 copy the contents of a rgb buffer rgb to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_getbox (s_surface_t *surface, int x, int y, int w, int h, void *dp)
 copy a rectangular bitmap at position (x, y) with size (w, h) from the surface to a buffer dp.
void s_putboxpart (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, void *sp, int xo, int yo)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxpartmask (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, char *sp, unsigned char *sm, int xo, int yo)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxpartrgb (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, unsigned int *rgb, int xo, int yo)
 copy the contents of a rgb buffer rgb to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxpartrgba (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, unsigned int *rgba, int xo, int yo)
 copy the contents of a rgba buffer rgba to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_putboxpartalpha (s_surface_t *surface, int x, int y, int w, int h, int bw, int bh, void *sp, unsigned char *sm, int xo, int yo)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.
void s_copybox (s_surface_t *surface, int x1, int y1, int w, int h, int x2, int y2)
 copy the rectangular area at (x1, y1) of size (w, h), to (x2, y2) (surface copy).
void s_getsurfacevirtual (s_surface_t *s, int w, int h, int bitspp, void *vbuf)
 sets surface (s), as virtual with the bitsperpixel of bitspp, width of w, and hight of h.
int s_copybuffer (char *sb, int sbitspp, char **db, int dbitspp, int w, int h)
 copies and converts the source buffer (sb) which is sbitspp bitsperpixel, to destination buffer (db) which is dbitspp bitsperpixel.
void s_rotatebox (s_surface_t *surface, s_rect_t *srect, void *sbuf, s_rect_t *drect, void *dbuf, int rotate)
 rotate the bitmap of size (srect) at sbuf to size (drect) and store it at dbuf, which must be a large enough buffer, with the angle of rotate.
void s_scalebox (s_surface_t *surface, int w1, int h1, void *_dp1, int w2, int h2, void *_dp2)
 scale the bitmap of size (w1, h1) at _dp1 to size (w2, h2) and store it at _dp2, which must be a large enough buffer.
int s_putmaskpart (unsigned char *dp, int dw, int dh, int x, int y, int w, int h, int bw, int bh, unsigned char *sp, int xo, int yo)
 copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the memory buffer dp.


Function Documentation

void s_colorrgb ( s_surface_t surface,
int  c,
int *  r,
int *  g,
int *  b 
)

return the red, green, and blue values for the given color

Parameters:
*surface - the surface
c - the color
*r - red (output)
*g - green (output)
*b - blue (output)
Returns:
no return

void s_copybox ( s_surface_t surface,
int  x1,
int  y1,
int  w,
int  h,
int  x2,
int  y2 
)

copy the rectangular area at (x1, y1) of size (w, h), to (x2, y2) (surface copy).

Parameters:
*surface - the surface
x1 - source x coordinate
y1 - source y coordinate
w - width
h - height
x2 - destination x coordinate
y2 - destination y coordinate
Returns:
no return

int s_copybuffer ( char *  sb,
int  sbitspp,
char **  db,
int  dbitspp,
int  w,
int  h 
)

copies and converts the source buffer (sb) which is sbitspp bitsperpixel, to destination buffer (db) which is dbitspp bitsperpixel.

db will be alocated internally.

Parameters:
*sb - source buffer
sbitspp - source bitsperpixel
**db - destination buffer
dbitspp - destination bitsperpixel
w - width
h - height
Returns:
0 on success

void s_fillbox ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  c 
)

fill a rectangular area at position (x, y) with size (w, h) of the screen with a single color c on to the surface

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
c - color value
Returns:
no return

void s_getbox ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
void *  dp 
)

copy a rectangular bitmap at position (x, y) with size (w, h) from the surface to a buffer dp.

pixmaps are in row-major order. the destination pixmap has the size w * h * surface->bytesperpixel

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*dp - destination pixmap
Returns:
no return

int s_getpixel ( s_surface_t surface,
int  x,
int  y 
)

gets the color value of the pixel form x, y coordinates of the surface

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
Returns:
the color value

void s_getpixelrgb ( s_surface_t surface,
int  x,
int  y,
int *  r,
int *  g,
int *  b 
)

gets the red, green, blue values of the pixel form x, y coordinates of the surface

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
*r - red value (output)
*g - green value (output)
*b - blue value (output)
Returns:
no return

void s_getsurfacevirtual ( s_surface_t s,
int  w,
int  h,
int  bitspp,
void *  vbuf 
)

sets surface (s), as virtual with the bitsperpixel of bitspp, width of w, and hight of h.

vbuf will be the virtual buffer of the surface. the source pixmap memory (vbuf) has the size w * h * bytesperpixel.

Parameters:
*s - the surface
w - width
h - height
bitspp - bitsperpixel
vbuf - virtual buffer
Returns:
no return

void s_hline ( s_surface_t surface,
int  x1,
int  y,
int  x2,
int  c 
)

draw a horizontal line from point (x1, y) to (x2, y) in color c on to the surface

Parameters:
*surface - the surface
x1 - start coordinate
y - y coordinate
x2 - end coordinate
c - color value
Returns:
no return

void s_line ( s_surface_t surface,
int  x1,
int  y1,
int  x2,
int  y2,
int  c 
)

draw a line from point (x1, y1) to (x2, y2) inclusively in color c

Parameters:
*surface - the surface
x1 - x start point
x2 - x end point
y1 - y start point
y2 - y end point
c - color value
Returns:
no return

void s_putbox ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
void *  sp 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

Pixmaps are in row-major order. the source pixmap memory has the size w * h * surface->bytesperpixel

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*sp - source pixmap
Returns:
no return

void s_putboxalpha ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
char *  sp,
unsigned char *  sm 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

pixmaps are in row-major order. the source pixmap memory has the size w * h * surface->bytesperpixel. this function works like s_putbox, but uses sm for alpha mask operations, sm[y * w + x] is the alpha value for corresponding pixel.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*sp - source pixmap
*sm - source mask
Returns:
no return

void s_putboxmask ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
char *  sp,
unsigned char *  sm 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

pixmaps are in row-major order. the source pixmap memory has the size w * h * surface->bytesperpixel. this function works like s_putbox, but uses sm for mask operations and does not write pixmap pixels if sm[y * w + x] == 0

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*sp - source pixmap
*sm - source mask
Returns:
no return

void s_putboxpart ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
void *  sp,
int  xo,
int  yo 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

however, only a part of size (w, h) starting at offset (xo, yo) in the pixmap is copied. pixmaps are in row-major order. the source pixmap memory has the size bw * bh * surface->bytesperpixel

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*sp - source pixmap
xo - x offset
yo - y offset
Returns:
no return

void s_putboxpartalpha ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
void *  sp,
unsigned char *  sm,
int  xo,
int  yo 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

however, only a part of size (bw, bh) starting at offset (xo, yo) in the pixmap is copied. pixmaps are in row-major order. the source pixmap memory has the size w * h * surface->bytesperpixel. this function works like s_putbox, but uses sm for alpha mask operations, sm[y * w + x] is the alpha value for corresponding pixel.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*sp - source pixmap
*sm - source mask
xo - x offset
yo - y offset
Returns:
no return

void s_putboxpartmask ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
char *  sp,
unsigned char *  sm,
int  xo,
int  yo 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

however, only a part of size (bw, bh) starting at offset (xo, yo) in the pixmap is copied. pixmaps are in row-major order. the source pixmap memory has the size w * h * surface->bytesperpixel. this function works like s_putbox, but uses sm for alpha mask operations, sm[y * w + x] is the alpha value for corresponding pixel.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*sp - source pixmap
*sm - source mask
xo - x offset
yo - y offset
Returns:
no return

void s_putboxpartrgb ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
unsigned int *  rgb,
int  xo,
int  yo 
)

copy the contents of a rgb buffer rgb to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

however, only a part of size (bw, bh) starting at offset (xo, yo) in the pixmap is copied.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*rgb - source pixmap rgb values
xo - x offset
yo - y offset
Returns:
no return

void s_putboxpartrgba ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
unsigned int *  rgba,
int  xo,
int  yo 
)

copy the contents of a rgba buffer rgba to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

however, only a part of size (bw, bh) starting at offset (xo, yo) in the pixmap is copied.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*rgba - source pixmap rgba values
xo - x offset
yo - y offset
Returns:
no return

void s_putboxrgb ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
unsigned int *  rgb 
)

copy the contents of a rgb buffer rgb to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*rgb - source pixmap rgb values
Returns:
no return

void s_putboxrgba ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
unsigned int *  rgba 
)

copy the contents of a rgba buffer rgba to a rectangular bitmap at position (x, y) with size (w, h) on to the surface.

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
w - width
h - height
*rgba - source pixmap rgba values
Returns:
no return

int s_putmaskpart ( unsigned char *  dp,
int  dw,
int  dh,
int  x,
int  y,
int  w,
int  h,
int  bw,
int  bh,
unsigned char *  sp,
int  xo,
int  yo 
)

copy the contents of a memory buffer sp to a rectangular bitmap at position (x, y) with size (w, h) on to the memory buffer dp.

however, only a part of size (w, h) starting at offset (xo, yo) in the pixmap is copied. pixmaps are in row-major order. the source pixmap memory has the size bw * bh * 1. this is a special copy function to use internally.

Parameters:
*dp - destination pixmap
*dw - destination width
*dh - destination height
x - x coordinate
y - y coordinate
w - width
h - height
bw - bitmap width
bh - bitmap heihgt
*sp - source pixmap
xo - x offset
yo - y offset
Returns:
no return

int s_rgbcolor ( s_surface_t surface,
int  r,
int  g,
int  b 
)

returns pixel value used in the current surface that corresponds with the given color components.

Parameters:
*surface - the surface
r - red
g - green
b - blue
Returns:
the calulated color value

void s_rotatebox ( s_surface_t surface,
s_rect_t srect,
void *  sbuf,
s_rect_t drect,
void *  dbuf,
int  rotate 
)

rotate the bitmap of size (srect) at sbuf to size (drect) and store it at dbuf, which must be a large enough buffer, with the angle of rotate.

Parameters:
*surface - the surface
*srect - source rectangle
*sbuf - source buffer
*drect - destination rectangle
*dbuf - destination buffer
rotate - rotate angle
Returns:
no return

void s_scalebox ( s_surface_t surface,
int  w1,
int  h1,
void *  _dp1,
int  w2,
int  h2,
void *  _dp2 
)

scale the bitmap of size (w1, h1) at _dp1 to size (w2, h2) and store it at _dp2, which must be a large enough buffer.

Parameters:
*surface - the surface
w1 - source width
h1 - source height
*_dp1 - source pixmap
w2 - destination width
h2 - destination height
*_dp2 - destination pixmap
Returns:
no return

void s_setpixel ( s_surface_t surface,
int  x,
int  y,
int  c 
)

puts one pixel color to the x, y coordinate on the surface

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
c - the color
Returns:
no return

void s_setpixelrgb ( s_surface_t surface,
int  x,
int  y,
int  r,
int  g,
int  b 
)

puts one pixel color to the x, y coordinate on the surface

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
r - red value
g - green value
b - blue value
Returns:
no return

void s_setpixelrgba ( s_surface_t surface,
int  x,
int  y,
int  r,
int  g,
int  b,
int  a 
)

puts one pixel color to the x, y coordinate on the surface (with alpha)

Parameters:
*surface - the surface
x - x coordinate
y - y coordinate
r - red value
g - green value
b - blue value
a - alpha value
Returns:
no return

void s_vline ( s_surface_t surface,
int  x,
int  y1,
int  y2,
int  c 
)

draw a vertical line from point (x, y1) to (x, y2) in color c on to the surface

Parameters:
*surface - the surface
x - x coordinate
y1 - start coordinate
y2 - end coordinate
c - color value
Returns:
no return


Generated on Wed Dec 27 17:53:06 2006 for xynth-0.8.40 by  doxygen 1.4.7