SDL3_gfx 1.0.1 Graphics primitives and surface functions for SDL3

SDL3_rotozoom.h
Go to the documentation of this file.
1/*
2
3 SDL3_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*/
29
30#ifndef _SDL3_rotozoom_h
31#define _SDL3_rotozoom_h
32
33#include <math.h>
34
35/* Set up for C function definitions, even when using C++ */
36#ifdef __cplusplus
37 extern "C" {
38#endif
39
40#ifndef M_PI
41#define M_PI 3.1415926535897932384626433832795
42#endif
43
44#include <SDL3/SDL.h>
45
46 /* ---- Defines */
47
51#define SMOOTHING_OFF 0
52
56#define SMOOTHING_ON 1
57
58 /* ---- Function Prototypes */
59
60#ifdef _MSC_VER
61# if defined(DLL_EXPORT) && !defined(LIBSDL3_GFX_DLL_IMPORT)
62# define SDL3_ROTOZOOM_SCOPE __declspec(dllexport)
63# else
64# ifdef LIBSDL3_GFX_DLL_IMPORT
65# define SDL3_ROTOZOOM_SCOPE __declspec(dllimport)
66# endif
67# endif
68#endif
69#ifndef SDL3_ROTOZOOM_SCOPE
70# define SDL3_ROTOZOOM_SCOPE extern
71#endif
72
73 /*
74
75 Rotozoom functions
76
77 */
78
79 SDL3_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
80
81 SDL3_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
82 (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
83
84
85 SDL3_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
86 int *dstheight);
87
88 SDL3_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
89 (int width, int height, double angle, double zoomx, double zoomy,
90 int *dstwidth, int *dstheight);
91
92 /*
93
94 Zooming functions
95
96 */
97
98 SDL3_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
99
100 SDL3_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
101
102 /*
103
104 Shrinking functions
105
106 */
107
108 SDL3_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
109
110 /*
111
112 Specialized rotation functions
113
114 */
115
116 SDL3_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
117
118 /* Ends C function definitions when using C++ */
119#ifdef __cplusplus
120}
121#endif
122
123#endif /* _SDL3_rotozoom_h */
rotozoomSurfaceSize
SDL3_ROTOZOOM_SCOPE 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.
Definition SDL3_rotozoom.c:992
shrinkSurface
SDL3_ROTOZOOM_SCOPE SDL_Surface * shrinkSurface(SDL_Surface *src, int factorx, int factory)
Shrink a surface by an integer ratio using averaging.
Definition SDL3_rotozoom.c:1487
rotateSurface90Degrees
SDL3_ROTOZOOM_SCOPE SDL_Surface * rotateSurface90Degrees(SDL_Surface *src, int numClockwiseTurns)
Rotates a 8/16/24/32 bit surface in increments of 90 degrees.
Definition SDL3_rotozoom.c:784
rotozoomSurfaceXY
SDL3_ROTOZOOM_SCOPE 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-...
Definition SDL3_rotozoom.c:1035
rotozoomSurfaceSizeXY
SDL3_ROTOZOOM_SCOPE 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.
Definition SDL3_rotozoom.c:975
zoomSurface
SDL3_ROTOZOOM_SCOPE SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
Definition SDL3_rotozoom.c:1338
zoomSurfaceSize
SDL3_ROTOZOOM_SCOPE 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.
Definition SDL3_rotozoom.c:1288
SDL3_ROTOZOOM_SCOPE
#define SDL3_ROTOZOOM_SCOPE
Definition SDL3_rotozoom.h:70
rotozoomSurface
SDL3_ROTOZOOM_SCOPE SDL_Surface * rotozoomSurface(SDL_Surface *src, double angle, double zoom, int smooth)
Rotates and zooms a surface and optional anti-aliasing.
Definition SDL3_rotozoom.c:1014