bx-lib : the Basic X11 Library tuned for C beginners  1.0
Functions
Drawing images
Drawing (what you can do with a pen on a canvas)

Functions

void bx_free_image (bx_image image)
bx_image bx_load_image (int transp, char const name[])
bx_image bx_load_image_f (int transp, char const format[],...)
unsigned bx_image_width (bx_image image)
unsigned bx_image_height (bx_image image)
void bx_flip_image (bx_image image, int xflip, int yflip)
void bx_draw_image (bx_window win, bx_image image, int x, int y)
void bx_draw_image_fx (bx_window win, bx_image image, int x, int y, bx_effect fx)

Detailed Description

Function Documentation

void bx_free_image ( bx_image  image)

Free the memory allocated by a loaded image.

Parameters
imagethe image to be freed.
Returns
nothing.
bx_image bx_load_image ( int  transp,
char const  name[] 
)

Loads an image from a file (jpg, gif, png, ...)

Parameters
transpwhether the image is fully opaque (zero) or has some transparency information (non zero).
namethe path and filename of the image.
Returns
the image along with its eventual transparency mask.
Remarks
  • on error (no memory available, file not found), the program simply exits!
  • half transparency (alpha channel) is not handled. A pixel is either fully opaque or fully transparent.
bx_image bx_load_image_f ( int  transp,
char const  format[],
  ... 
)

Loads an image from a file (jpg, gif, png, ...) just as bx_load_image() but with a printf()-like format to specify the path to the file.

Parameters
transpwhether the image is fully opaque (zero) or has some transparency information (non zero).
formatprintf()-like format string yielding the path to the image.
...the arguments corresponding to the %-pecifiers of the format.
Returns
the image along with its eventual transparency mask.
Remarks
  • on error (no memory available, file not found), the program simply exits!
  • half transparency (alpha channel) is not handled. A pixel is either fully opaque or fully transparent.
unsigned bx_image_width ( bx_image  image)

Gets the width of the loaded image in pixels.

Parameters
imagethe image whose size is queried
Returns
its width in pixels
unsigned bx_image_height ( bx_image  image)

Gets the height of the loaded image in pixels.

Parameters
imagethe image whose size is queried
Returns
its height in pixels
void bx_flip_image ( bx_image  image,
int  xflip,
int  yflip 
)

Sets the image in a horizontal/vertical mirrored state with respect to the image state at loading time.

Parameters
xflipboolean stating if the image should be displayed x-mirrored
yflipboolean stating if the image should be displayed y-mirrored
void bx_draw_image ( bx_window  win,
bx_image  image,
int  x,
int  y 
)

Draws an image on the canvas of a window.

Parameters
winthe window owning the targeted canvas.
imagethe image to draw on the canvas
x,ythe position of tha anchor of the image on the canvas, that is, its top left corner
Returns
nothing.
Remarks
void bx_draw_image_fx ( bx_window  win,
bx_image  image,
int  x,
int  y,
bx_effect  fx 
)

Draws an image on the canvas of a window, eventually combining the backgound of the canvas and the image with 1 special effect among 16.

Parameters
winthe window owning the targeted canvas.
imagethe image to draw on the canvas.
x,ythe position of thr anchor of the image on the canvas, that is, its top left corner.
fxthe special effect to apply, in the range from 0 to 15, see bx_effect for available effects.
Returns
nothing.
Remarks
  • images can be loaded from a file (gif, jpg, png, ...) with bx_load_image() or bx_load_image_f().
  • the direction of y-axis of the canvas is downward.
  • bx_draw_image_fx() with fx=3= BX_A is equivalent to bx_draw_image().
  • fx do not apply on transparent pixels of the image: the underlying pixels of the canvas will always be visible.