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