| 1 |
Converted to D by clayasaurus |
|---|
| 2 |
|
|---|
| 3 |
Rotozoom/Zoom function for SDL |
|---|
| 4 |
======================================================================================== |
|---|
| 5 |
|
|---|
| 6 |
(C) LGPL, A. Schiffler, aschiffler@cogeco.com - see LICENSE for details. |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
INTERFACE |
|---|
| 10 |
--------- |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
SDL_Surface * rotozoomSurface (SDL_Surface *src, double angle, double zoom, int smooth); |
|---|
| 14 |
|
|---|
| 15 |
Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. |
|---|
| 16 |
'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1 |
|---|
| 17 |
then the destination 32bit surface is anti-aliased. If the surface is not 8bit |
|---|
| 18 |
or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
SDL_Surface * zoomSurface (SDL_Surface *src, double zoomx, double zoomy, int smooth); |
|---|
| 23 |
|
|---|
| 24 |
Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. |
|---|
| 25 |
'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1 |
|---|
| 26 |
then the destination 32bit surface is anti-aliased. If the surface is not 8bit |
|---|
| 27 |
or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
Smoothing (interpolation) flags work only on 32bit surfaces: |
|---|
| 31 |
|
|---|
| 32 |
#define SMOOTHING_OFF 0 |
|---|
| 33 |
#define SMOOTHING_ON 1 |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
EXAMPLE |
|---|
| 37 |
------- |
|---|
| 38 |
|
|---|
| 39 |
Run |
|---|
| 40 |
./configure |
|---|
| 41 |
make |
|---|
| 42 |
|
|---|
| 43 |
Test with |
|---|
| 44 |
./testrotozoom |
|---|
| 45 |
|
|---|
| 46 |
Check out the testrotozoom.c code for how to preprocess non-32bit surfaces |
|---|
| 47 |
for better speed. |
|---|
| 48 |
|
|---|
| 49 |
Unzip VisualC.zip for VC projects files. |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
CHANGES |
|---|
| 53 |
------- |
|---|
| 54 |
|
|---|
| 55 |
Ver 1.6 - Mon Nov 19 21:19:26 EST 2001 |
|---|
| 56 |
* Added interpolation to alpha channel (simplifies code) |
|---|
| 57 |
* Ran the sourcecode through 'indent' for better readability |
|---|
| 58 |
|
|---|
| 59 |
Ver 1.5 - Sat Jul 7 13:02:07 EDT 2001 |
|---|
| 60 |
* Added project files (VisualC.zip) and modifications for VC project building. |
|---|
| 61 |
* Fixed old versioning in configure.in file. |
|---|
| 62 |
* Fixed LICENSE file and LGPL source reference. |
|---|
| 63 |
|
|---|
| 64 |
Ver 1.4 - Mon Jun 4 12:15:31 EDT 2001 |
|---|
| 65 |
* Removed SDL_SoftStretch call again in favour of an internal zoom routine. |
|---|
| 66 |
* Added new zoomSurface() function with seperate X and Y zoom factors. |
|---|
| 67 |
|
|---|
| 68 |
Ver 1.3 - Thu May 31 08:37:36 EDT 2001 |
|---|
| 69 |
* Modified code to handle RGBA or ABGR source surfaces transparently. |
|---|
| 70 |
* More error checking, source surface locking. |
|---|
| 71 |
* Slighly expanded test program with event handling. |
|---|
| 72 |
|
|---|
| 73 |
Ver 1.2 - Wed May 30 18:18:05 EDT 2001 |
|---|
| 74 |
* Fixed the completely broken 32bit routine's pointer arithmetic. |
|---|
| 75 |
* Uses SDL_SoftStretch in certain cases (angle=0, smooth=0). |
|---|
| 76 |
* Convert source surface on the fly if not 8/32bit. |
|---|
| 77 |
* Added license file - was empty before (duh). |
|---|
| 78 |
|
|---|
| 79 |
Ver 1.1 - Wed May 23 15:04:42 EDT 2001 |
|---|
| 80 |
* Added automake/autoconf scripts and testprogram. |
|---|
| 81 |
|
|---|
| 82 |
Ver 1.0 - Fri Mar 16 08:16:06 EST 2001 |
|---|
| 83 |
* Initial release |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
COMMENTS |
|---|
| 87 |
-------- |
|---|
| 88 |
|
|---|
| 89 |
SDL_rotozoom was designed to work with SDL Ver. 1.2 and higher - see |
|---|
| 90 |
http://www.libsdl.org for more info in the SDL library. |
|---|
| 91 |
|
|---|
| 92 |
The code is not super optimal - but it should be fast enough even for some |
|---|
| 93 |
realtime effects if the bitmaps are kept small. |
|---|
| 94 |
|
|---|
| 95 |
The routines are mostly ment to be used for pre-rendering stuff in higher |
|---|
| 96 |
quality (i.e. smoothing) - that's also a reason why the API differs from |
|---|
| 97 |
SDL_BlitRect() and creates new target surfaces. The final rendering speed |
|---|
| 98 |
is dependent on the target surface size as as it is beeing xy-scanned when |
|---|
| 99 |
rendering. |
|---|
| 100 |
|
|---|
| 101 |
Note also that the smoothing toggle is dependent on the input surface bit |
|---|
| 102 |
depth. 8bit surfaces will never be smoothed - only 32bit surfaces will. |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
CONTRIBUTORS |
|---|
| 106 |
------------ |
|---|
| 107 |
|
|---|
| 108 |
* VisualC project files and fixes from Giorgio Delmondo, giorgio@hurd.it - |
|---|
| 109 |
thanks Giorgio. |
|---|