Subsections
- struct map;
- map *ts_makebmp (int w, int h);
- map *ts_readbmp (char *file);
- void ts_killbmp (map *what);
- map *ts_tobmp (map *where);
- void ts_clrbmp (map *what, int color);
- void ts_blit (map *what, int dest_x, int dest_y);
- void ts_partblit (map *what, int src_x1, int src_y1, int src_x2, int src_y2,
int dest_x, int dest_y);
- void ts_stretchblit (map *what, float ratio, int dest_x, int
dest_y);
- void ts_flipblit (map *what, int flip, int dest_x, int dest_y);
- void ts_rotateblit (map *what, int cx, int cy, float angle, int dest_x, int
dest_y);
Defined in blit.h
and blit.c
Normally, all graphics functions draw onto the screen. It is also possible to draw onto a
memory bitmap, and blit that bitmap to the screen, once your drawing operations are finished.
This is necessary in cases where your stimulus is too complex to be drawn within one refresh
cycle of the screen. The double buffer also provides similar functionality.
The bitmap functions add the following:
- it is possible to have more than one bitmap in memory (increase program speed even
more)
- you can choose the size of the bitmap (save memory)
- you can load bitmaps from a .bmp file
- you can do special operations, like rotating, zooming, etc.
The destination coordinates of the blitting functions below are interpreted dependent on the
coordinate system used. With the Cartesian coordinate system, bitmaps are blitted centered
around the destination coordinates. With the standard coordinate system, the destination
coordinates correspond to the upper left corner of the blitting area.
Bitmap memory structure used by Tscope. It is defined as follows:
typedef struct {
int sw, sh;
int w, h;
BITMAP *b;
} map;
sw and sh contain the total width and height of the bitmap in pixels.
w and h contain the with and height of one quadrant of the bitmap (for use with the
Cartesian coordinate system).
b points to the content of the bitmap.
Creates a bitmap with dimensions w and h.
If you use the Cartesian coordinate system, w and h are interpreted as the horizontal and
vertical size of each quadrant of the bitmap. The center of the bitmap will be (0,0), x will
range from -w to +w, y from -h to +h.
If you use the standard coordinate system, w and h are interpreted as the horizontal and
vertical size of the whole bitmap. (0,0) will be the upper left corner of the bitmap, (w,h)
will be the lower right of the bitmap.
The default background color of the newly created bitmap is the same as the screen and
double buffer background color.
Returns the address of the newly created bitmap.
Creates a bitmap containing the bitmap-file.
Returns the address of the bitmap.
Removes the specified bitmap out of memory. You should do this at the end of
your program for all bitmaps created with ts_makebmp or ts_readbmp.
Defines one the specified bitmap as destination of the following drawing
operations.
Clears one of the self-made bitmaps. Color defines the background
color. You can either provide a color (pre-defined or by means of ts_makecolor), or you can use
the pre-defined TRANS and NONE values. TRANS makes the background transparent, while NONE takes
the background color of the screen and double buffer.
Blits the specified bitmap to the current destination
bitmap, at the position defined by (dest_x, dest_y).
Blits part of the specified bitmap to the current destination bitmap. (src_x1,
src_y1) en (src_x2, src_y2) are the coordinates of the rectangular part of the source bitmap.
The image is blitted at position (dest_x, dest_y).
Blits a magnified or scaled down
version of the specified bitmap to the destination bitmap at position (dest_x, dest_y). Ratio
defines the scale factor (1 = original size, >1 magnify, <1 scale down).
Flips and blits the specified bitmap to
the destination bitmap at position (dest_x, dest_y). With flip you provide type of flip. VFLIP
flips the bitmap vertically, while HFLIP results in a horizontal flip. VHFLIP combines both.
Rotates and blits the
specified bitmap to the destination bitmap at position (dest_x, dest_y). (cx, cy) Defines the
center of the rotation, angle defines the angle (0-360, counter-clockwise).