Tscope5
|
Definitions of bitmap functions. More...
Go to the source code of this file.
Functions | |
Loading bitmaps | |
Bitmaps can either be read from a file, or empty bitmaps can be generated. | |
TS5_BITMAP * | ts5_alloc_bitmap (double w, double h) |
Create a bitmap. More... | |
TS5_BITMAP * | ts5_read_bitmap (const char *file) |
Open a bitmap from a file. More... | |
void | ts5_write_bitmap (const char *file, TS5_BITMAP *map) |
Write a bitmap. More... | |
void | ts5_free_bitmap (TS5_BITMAP *map) |
Free the memory used by a bitmap. More... | |
Query bitmap dimensions | |
The dimensions of a bitmap can be queried using the functions below: | |
void | ts5_get_bitmap_size (TS5_BITMAP *map, double *w, double *h) |
Get the size of a bitmap in pixels. More... | |
double | ts5_get_bitmap_width (TS5_BITMAP *map) |
Get the width of a bitmap in pixels. More... | |
double | ts5_get_bitmap_height (TS5_BITMAP *map) |
Get the height of a bitmap in pixels. More... | |
Drawing on bitmaps | |
Text/primitives output that is normally drawn on the display can be redirected to a bitmap. | |
TS5_BITMAP * | ts5_set_drawing_target (TS5_BITMAP *target) |
Set the active drawing target. More... | |
TS5_BITMAP * | ts5_get_drawing_target () |
Get the active drawing target. More... | |
void | ts5_get_target_size (double *w, double *h) |
Get the total size of the drawing target in pixels. More... | |
double | ts5_get_target_width () |
Get the total width of the drawing target in pixels. More... | |
double | ts5_get_target_height () |
Get the total height of the drawing target in pixels. More... | |
Drawing bitmaps on the display | |
The destination coordinates of the bitmap drawing functions below are interpreted dependent on the coordinate system used.
| |
void | ts5_draw_bitmap (TS5_BITMAP *map, double dx, double dy) |
Draw a bitmap. More... | |
void | ts5_draw_flipped_bitmap (TS5_BITMAP *map, double dx, double dy, const int flip) |
Draw a flipped bitmap. More... | |
void | ts5_draw_tinted_bitmap (TS5_BITMAP *map, TS5_COLOR tint, double dx, double dy) |
Draw a tinted bitmap. More... | |
void | ts5_draw_bitmap_region (TS5_BITMAP *map, double sx1, double sy1, double sx2, double sy2, double dx, double dy) |
Draw a region of a bitmap. More... | |
void | ts5_draw_rotated_bitmap (TS5_BITMAP *map, double cx, double cy, double angle, double dx, double dy) |
Draw a rotated bitmap. More... | |
void | ts5_draw_scaled_bitmap (TS5_BITMAP *map, double xratio, double yratio, double dx, double dy) |
Draw a scaled bitmap. More... | |
Definitions of bitmap functions.
Definition in file bitmaps.c.
TS5_BITMAP* ts5_alloc_bitmap | ( | double | w, |
double | h | ||
) |
Create a bitmap.
w | Width of the bitmap. |
h | Height of the bitmap. |
The default background color of the newly created bitmap is the same as the display.
TS5_BITMAP* ts5_read_bitmap | ( | const char * | file | ) |
Open a bitmap from a file.
file | Path to the bitmap file. |
Available bitmap types are: bmp, pcx, tga, jpeg and png.
void ts5_write_bitmap | ( | const char * | file, |
TS5_BITMAP * | map | ||
) |
Write a bitmap.
file | Path to the bitmap file. |
map | Pointer to the bitmap that will be written. |
The extension specifies the file type. Available bitmap types are: bmp, pcx, tga, jpeg and png.
Useful for saving screenshots of the experiment.
Useful for creating complex stimuli beforehand.
void ts5_free_bitmap | ( | TS5_BITMAP * | map | ) |
Free the memory used by a bitmap.
map | pointer to the bitmap that will be freed. |
This function should be called at the end of the program for each bitmap allocated or read by the user.
void ts5_get_bitmap_size | ( | TS5_BITMAP * | map, |
double * | w, | ||
double * | h | ||
) |
Get the size of a bitmap in pixels.
map | The bitmap that will be queried. |
w | Variable that will store the width. |
h | Variable that will store the height. |
You can pass NULL for values you are not interested in.
ts5_alloc_bitmap(), ts5_read_bitmap(), primitives.c, textio.c
double ts5_get_bitmap_width | ( | TS5_BITMAP * | map | ) |
double ts5_get_bitmap_height | ( | TS5_BITMAP * | map | ) |
TS5_BITMAP* ts5_set_drawing_target | ( | TS5_BITMAP * | target | ) |
Set the active drawing target.
target | Pointer to the bitmap that will be used for drawing operations. |
TS5_BITMAP* ts5_get_drawing_target | ( | ) |
void ts5_get_target_size | ( | double * | w, |
double * | h | ||
) |
double ts5_get_target_width | ( | ) |
double ts5_get_target_height | ( | ) |
void ts5_draw_bitmap | ( | TS5_BITMAP * | map, |
double | dx, | ||
double | dy | ||
) |
Draw a bitmap.
map | The bitmap that will be drawn. |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |
void ts5_draw_flipped_bitmap | ( | TS5_BITMAP * | map, |
double | dx, | ||
double | dy, | ||
const int | flip | ||
) |
Draw a flipped bitmap.
map | The bitmap that will be drawn. |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |
flip | Direction of the flip. Can be TS5_FLIP_HORIZONTAL, TS5_FLIP_VERTICAL or TS5_FLIP_BOTH. |
void ts5_draw_tinted_bitmap | ( | TS5_BITMAP * | map, |
TS5_COLOR | tint, | ||
double | dx, | ||
double | dy | ||
) |
Draw a tinted bitmap.
map | The bitmap that will be drawn. |
tint | The tint color. All colors in the bitmap are multiplied with the color specified in tint. |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |
void ts5_draw_bitmap_region | ( | TS5_BITMAP * | map, |
double | sx1, | ||
double | sy1, | ||
double | sx2, | ||
double | sy2, | ||
double | dx, | ||
double | dy | ||
) |
Draw a region of a bitmap.
map | The bitmap that will be drawn. |
sx1 | Horizontal coordinate of the first corner or the region. |
sy1 | Vertical coordinate of the first corner or the region. |
sx2 | Horizontal coordinate of the second corner or the region. |
sy2 | Vertical coordinate of the second corner or the region. |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |
void ts5_draw_rotated_bitmap | ( | TS5_BITMAP * | map, |
double | cx, | ||
double | cy, | ||
double | angle, | ||
double | dx, | ||
double | dy | ||
) |
Draw a rotated bitmap.
map | The bitmap that will be drawn. |
cx | Horizontal coordinate of the center of rotation. |
cy | Certical coordinate of the center of rotation. |
angle | The angle of rotation in degrees (positive is counter clockwise, negative is clockwise). |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |
The center of rotation (cx,cy) will be drawn at (dx,dy).
void ts5_draw_scaled_bitmap | ( | TS5_BITMAP * | map, |
double | xratio, | ||
double | yratio, | ||
double | dx, | ||
double | dy | ||
) |
Draw a scaled bitmap.
map | The bitmap that will be drawn. |
xratio | The scaling factor in the horizontal direction. |
yratio | The scaling factor in the vertical direction. |
dx | Horizontal position where it will be drawn. |
dy | Vertical position where it will be drawn. |