SDL_rotozoom.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. SDL_rotozoom - rotozoomer
  3. LGPL (c) A. Schiffler
  4. */
  5. #ifndef _SDL_rotozoom_h
  6. #define _SDL_rotozoom_h
  7. #include <math.h>
  8. /* Set up for C function definitions, even when using C++ */
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifndef M_PI
  13. #define M_PI 3.141592654
  14. #endif
  15. #include "SDL.h"
  16. /* ---- Defines */
  17. #define SMOOTHING_OFF 0
  18. #define SMOOTHING_ON 1
  19. /* ---- Structures */
  20. typedef struct tColorRGBA {
  21. Uint8 r;
  22. Uint8 g;
  23. Uint8 b;
  24. Uint8 a;
  25. } tColorRGBA;
  26. typedef struct tColorY {
  27. Uint8 y;
  28. } tColorY;
  29. /* ---- Prototypes */
  30. #ifdef WIN32
  31. #ifdef BUILD_DLL
  32. #define DLLINTERFACE __declspec(dllexport)
  33. #else
  34. #define DLLINTERFACE __declspec(dllimport)
  35. #endif
  36. #else
  37. #define DLLINTERFACE
  38. #endif
  39. /*
  40. rotozoomSurface()
  41. Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  42. 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
  43. then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  44. or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  45. */
  46. SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
  47. SDL_Surface *rotozoomSurfaceXY
  48. (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
  49. /* Returns the size of the target surface for a rotozoomSurface() call */
  50. void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
  51. int *dstheight);
  52. void rotozoomSurfaceSizeXY
  53. (int width, int height, double angle, double zoomx, double zoomy,
  54. int *dstwidth, int *dstheight);
  55. /*
  56. zoomSurface()
  57. Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  58. 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
  59. then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  60. or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  61. */
  62. SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
  63. /* Returns the size of the target surface for a zoomSurface() call */
  64. void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
  65. /*
  66. shrinkSurface()
  67. Shrinks a 32bit or 8bit 'src' surface ti a newly created 'dst' surface.
  68. 'factorx' and 'factory' are the shrinking ratios (i.e. 2=1/2 the size,
  69. 3=1/3 the size, etc.) The destination surface is antialiased by averaging
  70. the source box RGBA or Y information. If the surface is not 8bit
  71. or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  72. */
  73. SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
  74. /* Ends C function definitions when using C++ */
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif /* _SDL_rotozoom_h */