actual version
[sdl-headers.git] / SDL2_image.pas
1 unit sdl2_image;
2
3 {*
4   SDL_image:  An example image loading library for use with SDL
5   Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
6
7   Pascal-Header-Translation 2013 by Tim Blume
8
9   Both, header translation and sdl_image, under following license:
10
11   This software is provided 'as-is', without any express or implied
12   warranty.  In no event will the authors be held liable for any damages
13   arising from the use of this software.
14
15   Permission is granted to anyone to use this software for any purpose,
16   including commercial applications, and to alter it and redistribute it
17   freely, subject to the following restrictions:
18
19   1. The origin of this software must not be misrepresented; you must not
20      claim that you wrote the original software. If you use this software
21      in a product, an acknowledgment in the product documentation would be
22      appreciated but is not required.
23   2. Altered source versions must be plainly marked as such, and must not be
24      misrepresented as being the original software.
25   3. This notice may not be removed or altered from any source distribution.
26
27   ChangeLog (Header-Translation):
28   -------------------------------
29
30   v.1.72-stable; 29.09.2013: fixed bug with procedure without parameters 
31                              (they must have brackets)
32   v.1.70-stable; 11.09.2013: MacOS compatibility (with Delphi)
33   v.1.33-Alpha; 31.07.2013: Initial Commit
34
35 *}
36
37 {$DEFINE SDL_IMAGE}
38
39 {$I jedi.inc}
40
41 interface
42
43 uses
44   SDL2;
45
46 const
47   {$IFDEF WINDOWS}
48     IMG_LibName = 'SDL2_image.dll';
49   {$ENDIF}
50
51   {$IFDEF UNIX}
52     {$IFDEF DARWIN}
53       IMG_LibName = 'libSDL_image.dylib';
54     {$ELSE}
55       {$IFDEF FPC}
56         IMG_LibName = 'libSDL_image.so';
57       {$ELSE}
58         IMG_LibName = 'libSDL_image.so.0';
59       {$ENDIF}
60     {$ENDIF}
61   {$ENDIF}
62
63   {$IFDEF MACOS}
64     IMG_LibName = 'SDL2_image';
65     {$IFDEF FPC}
66       {$linklib libSDL2_image}
67     {$ENDIF}
68   {$ENDIF}
69
70   {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *}
71   SDL_IMAGE_MAJOR_VERSION = 2;
72   SDL_IMAGE_MINOR_VERSION = 0;
73   SDL_IMAGE_PATCHLEVEL    = 0;
74
75   {* This macro can be used to fill a version structure with the compile-time
76    * version of the SDL_image library.
77    *}
78
79 procedure SDL_IMAGE_VERSION(var X: TSDL_Version);
80
81   {* This function gets the version of the dynamically linked SDL_image library.
82      it should NOT be used to fill a version structure, instead you should
83      use the SDL_IMAGE_VERSION() macro.
84    *}
85 function IMG_Linked_Version: TSDL_Version cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_Linked_Version' {$ENDIF} {$ENDIF};
86
87 const
88   IMG_INIT_JPG  = $00000001;
89   IMG_INIT_PNG  = $00000002;
90   IMG_INIT_TIF  = $00000004;
91   IMG_INIT_WEBP = $00000008;
92
93 type
94   TIMG_InitFlags = DWord;
95
96   {* Loads dynamic libraries and prepares them for use.  Flags should be
97      one or more flags from IMG_InitFlags OR'd together.
98      It returns the flags successfully initialized, or 0 on failure.
99    *}
100 function IMG_Init(flags: SInt32): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_Init' {$ENDIF} {$ENDIF};
101
102   {* Unloads libraries loaded with IMG_Init *}
103 procedure IMG_Quit() cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_Quit' {$ENDIF} {$ENDIF};
104
105   {* Load an image from an SDL data source.
106      The 'type' may be one of: "BMP", "GIF", "PNG", etc.
107
108      If the image format supports a transparent pixel, SDL will set the
109      colorkey for the surface.  You can enable RLE acceleration on the
110      surface afterwards by calling:
111       SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
112    *}
113 function IMG_LoadTyped_RW(src: PSDL_RWops; freesrc: SInt32; _type: PAnsiChar): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTyped_RW' {$ENDIF} {$ENDIF};
114   {* Convenience functions *}
115 function IMG_Load(_file: PAnsiChar): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_Load' {$ENDIF} {$ENDIF};
116 function IMG_Load_RW(src: PSDL_RWops; freesrc: SInt32): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_Load_RW' {$ENDIF} {$ENDIF};
117
118   {* Load an image directly into a render texture. *}
119 function IMG_LoadTexture(renderer: PSDL_Renderer; _file: PAnsiChar): PSDL_Texture cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTexture' {$ENDIF} {$ENDIF};
120 function IMG_LoadTexture_RW(renderer: PSDL_Renderer; src: PSDL_RWops; freesrc: SInt32): PSDL_Texture cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTexture_RW' {$ENDIF} {$ENDIF};
121 function IMG_LoadTextureTyped_RW(renderer: PSDL_Renderer; src: PSDL_RWops; freesrc: SInt32; _type: PAnsiChar): PSDL_Texture cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTextureTyped_RW' {$ENDIF} {$ENDIF};
122
123   {* Functions to detect a file type, given a seekable source *}
124 function IMG_isICO(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isICO' {$ENDIF} {$ENDIF};
125 function IMG_isCUR(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isCUR' {$ENDIF} {$ENDIF};
126 function IMG_isBMP(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isBMP' {$ENDIF} {$ENDIF};
127 function IMG_isGIF(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isGIF' {$ENDIF} {$ENDIF};
128 function IMG_isJPG(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isJPG' {$ENDIF} {$ENDIF};
129 function IMG_isLBM(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isLBM' {$ENDIF} {$ENDIF};
130 function IMG_isPCX(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isPCX' {$ENDIF} {$ENDIF};
131 function IMG_isPNG(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isPNG' {$ENDIF} {$ENDIF};
132 function IMG_isPNM(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isPNM' {$ENDIF} {$ENDIF};
133 function IMG_isTIF(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isTIF' {$ENDIF} {$ENDIF};
134 function IMG_isXCF(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '-IMG_isXCF' {$ENDIF} {$ENDIF};
135 function IMG_isXPM(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isXPM' {$ENDIF} {$ENDIF};
136 function IMG_isXV(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isXV' {$ENDIF} {$ENDIF};
137 function IMG_isWEBP(src: PSDL_RWops): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_isWEBP' {$ENDIF} {$ENDIF};
138
139   {* Individual loading functions *}
140 function IMG_LoadICO_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadICO_RW' {$ENDIF} {$ENDIF};
141 function IMG_LoadCUR_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadCUR_RW' {$ENDIF} {$ENDIF};
142 function IMG_LoadBMP_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadBMP_RW' {$ENDIF} {$ENDIF};
143 function IMG_LoadGIF_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadGIF_RW' {$ENDIF} {$ENDIF};
144 function IMG_LoadJPG_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadJPG_RW' {$ENDIF} {$ENDIF};
145 function IMG_LoadLBM_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadLBM_RW' {$ENDIF} {$ENDIF};
146 function IMG_LoadPCX_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadPCX_RW' {$ENDIF} {$ENDIF};
147 function IMG_LoadPNG_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadPNG_RW' {$ENDIF} {$ENDIF};
148 function IMG_LoadPNM_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadPNM_RW' {$ENDIF} {$ENDIF};
149 function IMG_LoadTGA_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTGA_RW' {$ENDIF} {$ENDIF};
150 function IMG_LoadTIF_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadTIF_RW' {$ENDIF} {$ENDIF};
151 function IMG_LoadXCF_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadXCF_RW' {$ENDIF} {$ENDIF};
152 function IMG_LoadXPM_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadXMP_RW' {$ENDIF} {$ENDIF};
153 function IMG_LoadXV_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadXV_RW' {$ENDIF} {$ENDIF};
154 function IMG_LoadWEBP_RW(src: PSDL_RWops): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_LoadWEBP_RW' {$ENDIF} {$ENDIF};
155
156 function IMG_ReadXPMFromArray(xpm: PPChar): PSDL_Surface cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_ReadXPMFromArray' {$ENDIF} {$ENDIF};
157
158   {* Individual saving functions *}
159 function IMG_SavePNG(surface: PSDL_Surface; const _file: PAnsiChar): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_SavePNG' {$ENDIF} {$ENDIF};
160 function IMG_SavePNG_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: SInt32): SInt32 cdecl; external IMG_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_IMG_SavePNG_RW' {$ENDIF} {$ENDIF};
161
162 {* We'll use SDL for reporting errors *}
163 function IMG_SetError(fmt: PAnsiChar): SInt32;
164 function IMG_GetError: PAnsiChar;
165
166 implementation
167
168 procedure SDL_IMAGE_VERSION(var X: TSDL_Version);
169 begin
170   X.major := SDL_IMAGE_MAJOR_VERSION;
171   X.minor := SDL_IMAGE_MINOR_VERSION;
172   X.patch := SDL_IMAGE_PATCHLEVEL;
173 end;
174
175 function IMG_SetError(fmt: PAnsiChar): SInt32;
176 begin
177   Result := SDL_SetError(fmt);
178 end;
179
180 function IMG_GetError: PAnsiChar;
181 begin
182   Result := SDL_GetError;
183 end;
184
185 end.