Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

162 rader
6.7 KiB

  1. /*
  2. SDL_image: An example image loading library for use with SDL
  3. Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* A simple library to load images of various formats as SDL surfaces */
  19. #ifndef SDL_IMAGE_H_
  20. #define SDL_IMAGE_H_
  21. #include "SDL.h"
  22. #include "SDL_version.h"
  23. #include "begin_code.h"
  24. /* Set up for C function definitions, even when using C++ */
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  29. */
  30. #define SDL_IMAGE_MAJOR_VERSION 2
  31. #define SDL_IMAGE_MINOR_VERSION 0
  32. #define SDL_IMAGE_PATCHLEVEL 4
  33. /* This macro can be used to fill a version structure with the compile-time
  34. * version of the SDL_image library.
  35. */
  36. #define SDL_IMAGE_VERSION(X) \
  37. { \
  38. (X)->major = SDL_IMAGE_MAJOR_VERSION; \
  39. (X)->minor = SDL_IMAGE_MINOR_VERSION; \
  40. (X)->patch = SDL_IMAGE_PATCHLEVEL; \
  41. }
  42. /**
  43. * This is the version number macro for the current SDL_image version.
  44. */
  45. #define SDL_IMAGE_COMPILEDVERSION \
  46. SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL)
  47. /**
  48. * This macro will evaluate to true if compiled with SDL_image at least X.Y.Z.
  49. */
  50. #define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
  51. (SDL_IMAGE_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
  52. /* This function gets the version of the dynamically linked SDL_image library.
  53. it should NOT be used to fill a version structure, instead you should
  54. use the SDL_IMAGE_VERSION() macro.
  55. */
  56. extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void);
  57. typedef enum
  58. {
  59. IMG_INIT_JPG = 0x00000001,
  60. IMG_INIT_PNG = 0x00000002,
  61. IMG_INIT_TIF = 0x00000004,
  62. IMG_INIT_WEBP = 0x00000008
  63. } IMG_InitFlags;
  64. /* Loads dynamic libraries and prepares them for use. Flags should be
  65. one or more flags from IMG_InitFlags OR'd together.
  66. It returns the flags successfully initialized, or 0 on failure.
  67. */
  68. extern DECLSPEC int SDLCALL IMG_Init(int flags);
  69. /* Unloads libraries loaded with IMG_Init */
  70. extern DECLSPEC void SDLCALL IMG_Quit(void);
  71. /* Load an image from an SDL data source.
  72. The 'type' may be one of: "BMP", "GIF", "PNG", etc.
  73. If the image format supports a transparent pixel, SDL will set the
  74. colorkey for the surface. You can enable RLE acceleration on the
  75. surface afterwards by calling:
  76. SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
  77. */
  78. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type);
  79. /* Convenience functions */
  80. extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
  81. extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
  82. #if SDL_VERSION_ATLEAST(2,0,0)
  83. /* Load an image directly into a render texture.
  84. */
  85. extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file);
  86. extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc);
  87. extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type);
  88. #endif /* SDL 2.0 */
  89. /* Functions to detect a file type, given a seekable source */
  90. extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src);
  91. extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src);
  92. extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
  93. extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
  94. extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
  95. extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
  96. extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
  97. extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
  98. extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
  99. extern DECLSPEC int SDLCALL IMG_isSVG(SDL_RWops *src);
  100. extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
  101. extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
  102. extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
  103. extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
  104. extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src);
  105. /* Individual loading functions */
  106. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
  107. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src);
  108. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
  109. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
  110. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
  111. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
  112. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
  113. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
  114. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
  115. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSVG_RW(SDL_RWops *src);
  116. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
  117. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
  118. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
  119. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
  120. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
  121. extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src);
  122. extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
  123. /* Individual saving functions */
  124. extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file);
  125. extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
  126. extern DECLSPEC int SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality);
  127. extern DECLSPEC int SDLCALL IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality);
  128. /* We'll use SDL for reporting errors */
  129. #define IMG_SetError SDL_SetError
  130. #define IMG_GetError SDL_GetError
  131. /* Ends C function definitions when using C++ */
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #include "close_code.h"
  136. #endif /* SDL_IMAGE_H_ */