ManaPlus
SDL2_rotozoom.h
Go to the documentation of this file.
1 /*
2 
3 SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
4 
5 Copyright (C) 2012-2014 Andreas Schiffler
6 
7 This software is provided 'as-is', without any express or implied
8 warranty. In no event will the authors be held liable for any damages
9 arising from the use of this software.
10 
11 Permission is granted to anyone to use this software for any purpose,
12 including commercial applications, and to alter it and redistribute it
13 freely, subject to the following restrictions:
14 
15 1. The origin of this software must not be misrepresented; you must not
16 claim that you wrote the original software. If you use this software
17 in a product, an acknowledgment in the product documentation would be
18 appreciated but is not required.
19 
20 2. Altered source versions must be plainly marked as such, and must not be
21 misrepresented as being the original software.
22 
23 3. This notice may not be removed or altered from any source
24 distribution.
25 
26 Andreas Schiffler -- aschiffler at ferzkopp dot net
27 
28 Changed for ManaPlus (C) 2013-2017 ManaPlus developers
29 
30 */
31 
32 #ifndef _SDL2_rotozoom_h
33 #define _SDL2_rotozoom_h
34 
35 #include <math.h>
36 
37 /* Set up for C function definitions, even when using C++ */
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 #ifndef M_PI
44 #define M_PI 3.1415926535897932384626433832795
45 #endif
46 
47 #include "localconsts.h"
48 
49 PRAGMA48(GCC diagnostic push)
50 PRAGMA48(GCC diagnostic ignored "-Wshadow")
51 #include <SDL.h>
52 PRAGMA48(GCC diagnostic pop)
53 
54  /* ---- Defines */
55 
56 
59 #define SMOOTHING_OFF 0
60 
64 #define SMOOTHING_ON 1
65 
66  /* ---- Function Prototypes */
67 
68 #ifdef _MSC_VER
69 # if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
70 # define SDL2_ROTOZOOM_SCOPE __declspec(dllexport)
71 # else
72 # ifdef LIBSDL2_GFX_DLL_IMPORT
73 # define SDL2_ROTOZOOM_SCOPE __declspec(dllimport)
74 # endif
75 # endif
76 #endif
77 #ifndef SDL2_ROTOZOOM_SCOPE
78 # define SDL2_ROTOZOOM_SCOPE extern
79 #endif
80 
81  /*
82 
83  Rotozoom functions
84 
85  */
86 
87  SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
88 
90  (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
91 
92 
93  SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
94  int *dstheight);
95 
97  (int width, int height, double angle, double zoomx, double zoomy,
98  int *dstwidth, int *dstheight);
99 
100  /*
101 
102  Zooming functions
103 
104  */
105 
106  SDL2_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
107 
108  SDL2_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
109 
110  /*
111 
112  Shrinking functions
113 
114  */
115 
116  SDL2_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
117 
118  /*
119 
120  Specialized rotation functions
121 
122  */
123 
124  SDL2_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
125 
126  /* Ends C function definitions when using C++ */
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* _SDL2_rotozoom_h */
SDL_Surface * rotozoomSurface(SDL_Surface *src, double angle, double zoom, int smooth)
Rotates and zooms a surface and optional anti-aliasing.
SDL_Surface * rotateSurface90Degrees(SDL_Surface *src, int numClockwiseTurns)
Rotates a 8/16/24/32 bit surface in increments of 90 degrees.
void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight)
Calculates the size of the target surface for a zoomSurface() call.
void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight)
Returns the size of the resulting target surface for a rotozoomSurface() call.
SDL_Surface * rotozoomSurfaceXY(SDL_Surface *src, double angle, double zoomx, double zoomy, int smooth)
Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-...
SDL_Surface * shrinkSurface(SDL_Surface *src, int factorx, int factory)
Shrink a surface by an integer ratio using averaging.
#define SDL2_ROTOZOOM_SCOPE
Definition: SDL2_rotozoom.h:78
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
void rotozoomSurfaceSizeXY(int width, int height, double angle, double zoomx, double zoomy, int *dstwidth, int *dstheight)
Returns the size of the resulting target surface for a rotozoomSurfaceXY() call.
#define PRAGMA48(str)
Definition: localconsts.h:199