This documentation describes anti-aliased stretching and rotation routines for Allegro.
Allegro is a game programming library. Read more about it on Allegro's homepage:
http://www.talula.demon.co.uk/allegro/
Sorry, I can not explain the term anti-aliasing. You can use anti-aliasing routines included in this package to make graphics look smoother, when you scale or rotate it.
Steps for installing this package are simple: unpack, build and install in system directories. Let's pretend that you have correctly installed DJGPP and Allegro, and everything work like God, DJ Delorie and Shawn Hargreaves intended. I will assume that DJGPP is installed in `c:/djgpp' directory. If not, then replace `c:/djgpp' below with path to your DJGPP installation. I will assume that you are using bash as a shell, but these instructions should work with most other shells as well.
Unpack the package, preserving directory structure (use `-d' switch for pkunzip)
bash> unzip aastr.zip
If you are unpacking on Unix system with Info-Zip's unzip program, you may wish to automatically convert text files to Unix style by using `-a' switch of unzip program.
Build library and test programs. This package uses make
utility
for automating build process, just run make
in the `aastr'
directory
bash> cd aastr bash> make
Install library and header file by using make
utility
bash> make install
or by hands
bash> cp libaastr.a c:/djgpp/lib/ bash> cp aastr.h c:/djgpp/include/
Optionally, you can build and install documentation in info format.
Again, use make
utility
bash> make info bash> make install-info
Or just copy `aastr.info' to `c:/djgpp/info/' directory.
After running make
in the package directory, you will have two
test programs, `rottest.exe' and `strtest.exe'. Use `-Z'
switch to obtain information about supported switches. If you don't
have these programs, it means that there were problems in build process,
and you should investigate what went wrong.
There are some limitations common for all these functions. Source bitmap must be memory bitmap and destination bitmap must not be mode-X or Xtended mode bitmap. Source and destination bitmaps may have different color-depths. All functions respect clipping (or no clipping) for destination bitmap.
aa_stretch_blit
function above,
but it skips pixels in destination bitmap that are made mostly from
transparent pixels in source bitmap. It stretches the whole src
source bitmap.
rotate_scaled_sprite
it does not skip transparent
pixels, has distinct scaling parameters for x and y coordinates, and
x and y parameters specify location in destination bitmap
where to place center of rotated and scaled source bitmap.
aa_rotate_scaled_bitmap
function
above, but it skips pixels in destination bitmap that are made mostly
from transparent pixels in source bitmap.
aa_rotate_scaled_bitmap
function
above, but source bitmap is not scaled.
aa_rotate_scaled_sprite
function
above, but source bitmap is not scaled.
If destination bitmap is 8-bpp bitmap, you can speed up color conversion by setting global rgb map. For example
RGB_MAP rgb_table; create_rgb_table (&rgb_table, pallete, 0); rgb_map = &rgb_table;
Before using any of these routines in your program, include `aastr.h' header file. Link your program with `libaastr.a' library by passing `-laastr' option to gcc before `-lalleg' option.
Here is a short example program. If you want to make it run in 8-bpp mode, you should create and set pallete first (for example gray scale pallete).
#include <allegro.h> #include <stdio.h> #include <stdlib.h> #include <aastr.h> int main (int _argc, char *_argv[]) { int white; int black; BITMAP *bmp; /* Initialize Allegro library. */ allegro_init (); /* Install keyboard handler (for readkey). */ install_keyboard (); /* Choose 16-bpp color-depth. */ set_color_depth (16); /* Try to set graphics mode. */ if (set_gfx_mode (GFX_AUTODETECT, 640, 480, 0, 0) < 0) { fprintf (stderr, "%s: set_gfx_mode failed\n", _argv[0]); exit (1); } /* Create bitmap (make room for 12 8x8 character cells). */ bmp = create_bitmap (12 * 8 + 2, 8 + 2); if (bmp == 0) { allegro_exit (); fprintf (stderr, "%s: create_bitmap failed\n", _argv[0]); exit (1); } /* Make white and black colors. */ black = makecol (0, 0, 0); white = makecol (255, 255, 255); /* Clear bitmap with white color. */ clear_to_color (bmp, white); /* Print black text, using default 8x8 font. */ text_mode (-1); textout (bmp, font, "Hello, World", 1, 1, black); /* Stretch bitmap to screen. */ stretch_blit (bmp, screen, 0, 0, bmp->w, bmp->h, 0, 0, SCREEN_W, SCREEN_H / 2); /* Stretch bitmap to screen with anti-aliasing. */ aa_stretch_blit (bmp, screen, 0, 0, bmp->w, bmp->h, 0, SCREEN_H / 2, SCREEN_W, SCREEN_H / 2); /* Wait for any key. */ readkey (); return 0; }
Type this example into `test.c' and compile with the following commands
bash> gcc -c test.c bash> gcc -o test.exe test.o -laastr -lalleg
Anti-aliased stretching and rotation routines for Allegro are gift-ware. This package is given to you freely as a gift. You may use, modify, redistribute, and generally hack it about in any way you like, and you do not have to give anyone anything in return.
I do not accept any responsibility for any effects, adverse or otherwise, that this code may have on just about anything that you can think of. Use it at your own risk.
Anti-aliased stretching and rotation routines in this package were written by Michael Bukin bukinm@inp.nsk.su.
Idea for anti-aliased stretching and sample graphics file
(`to.pcx') were taken from aaStretch
routines written by
Przemyslaw Arkadiusz Podsiadly
ppodsiad@elka.pw.edu.pl.
This document was generated on 13 Febuary 1999 using the texi2html translator version 1.52.