[AD] interpolating rotation routines |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Hallo! Some days ago I created a set of sprite rotation routines that use bilinear interpolation for smoothing the pictures. After 4 days of optimizing they're now so fast that my game can actually use them. According to what my test program says they have about 40% the speed of the original routines. That test program (`exrot_i.c') and the rotation routines are included in the attached archive. The makefile should compile them in dos and Unix. If you like to add these routines to the Allegro library, just add the few `AL_FUNC' lines from `rotate_i.h' to `allegro.h' and concatenate the contents of `rotate_i.c' to Allegro's `src/rotate.c'. Please note that the interpolation is performed on RGB values rather than HSV. This is many times faster but it's not perfect. Very high contrast pictures may be displayed a little incorrectly. Another point to mention is, that edges between transparent pixels and non-transparent pixels are smoothed by interpolating with the background pixels. This kind of smoothing is not done at the sprite's borders. That's why sprites which need smooth edges should be surrounded by a border of transparent pixels. This method is necessary to make it possible to use rotated sprites for tiling. During development I noticed that `makecol' sometimes returns strange colors in 8bit mode. Try the program `maybebug.c', included in the attached archive and you'll see what I mean. That program tries to generate gradients from red, green and blue to white. For some reason the blue->white gradient contains some very dark colors. Note that I'm using Allegro version 3.9.30 (WIP). Bye, David Kühling
Attachment:
rotate_ip.tar.gz
Description: GNU Zip compressed data
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |