New comit of SDL2
[supertux.git] / src / SDL2 / SDL_image.h
1 /*
2   SDL_image:  An example image loading library for use with SDL
3   Copyright (C) 1997-2013 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    0
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 /* 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
58 typedef enum
59 {
60     IMG_INIT_JPG = 0x00000001,
61     IMG_INIT_PNG = 0x00000002,
62     IMG_INIT_TIF = 0x00000004,
63     IMG_INIT_WEBP = 0x00000008
64 } IMG_InitFlags;
65
66 /* Loads dynamic libraries and prepares them for use.  Flags should be
67    one or more flags from IMG_InitFlags OR'd together.
68    It returns the flags successfully initialized, or 0 on failure.
69  */
70 extern DECLSPEC int SDLCALL IMG_Init(int flags);
71
72 /* Unloads libraries loaded with IMG_Init */
73 extern DECLSPEC void SDLCALL IMG_Quit(void);
74
75 /* Load an image from an SDL data source.
76    The 'type' may be one of: "BMP", "GIF", "PNG", etc.
77
78    If the image format supports a transparent pixel, SDL will set the
79    colorkey for the surface.  You can enable RLE acceleration on the
80    surface afterwards by calling:
81     SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
82  */
83 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type);
84 /* Convenience functions */
85 extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
86 extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
87
88 #if SDL_VERSION_ATLEAST(2,0,0)
89 /* Load an image directly into a render texture.
90  */
91 extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file);
92 extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc);
93 extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type);
94 #endif /* SDL 2.0 */
95
96 /* Functions to detect a file type, given a seekable source */
97 extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src);
98 extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src);
99 extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
100 extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
101 extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
102 extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
103 extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
104 extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
105 extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
106 extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
107 extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
108 extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
109 extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
110 extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src);
111
112 /* Individual loading functions */
113 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
114 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src);
115 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
116 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
117 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
118 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
119 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
120 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
121 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
122 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
123 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
124 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
125 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
126 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
127 extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src);
128
129 extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
130
131 /* Individual saving functions */
132 extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file);
133 extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
134
135 /* We'll use SDL for reporting errors */
136 #define IMG_SetError    SDL_SetError
137 #define IMG_GetError    SDL_GetError
138
139 /* Ends C function definitions when using C++ */
140 #ifdef __cplusplus
141 }
142 #endif
143 #include "close_code.h"
144
145 #endif /* _SDL_IMAGE_H */