SDL_image.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 08 Nov 2009 15:53:24 +0000
changeset 233 fd5471011130
parent 226 19ed5821427f
child 234 cefead35d5c7
permissions -rw-r--r--
Sam Lantinga - Sun Nov 8 07:52:11 PST 2009
* Fixed checking for IMG_Init() return value in image loaders
slouken@0
     1
/*
slouken@52
     2
    SDL_image:  An example image loading library for use with SDL
slouken@186
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@0
     4
slouken@52
     5
    This library is free software; you can redistribute it and/or
slouken@121
     6
    modify it under the terms of the GNU Lesser General Public
slouken@52
     7
    License as published by the Free Software Foundation; either
slouken@121
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@52
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@52
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@121
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@121
    15
    You should have received a copy of the GNU Lesser General Public
slouken@121
    16
    License along with this library; if not, write to the Free Software
slouken@121
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@52
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
/* A simple library to load images of various formats as SDL surfaces */
slouken@0
    24
slouken@90
    25
#ifndef _SDL_IMAGE_H
slouken@90
    26
#define _SDL_IMAGE_H
slouken@0
    27
slouken@0
    28
#include "SDL.h"
slouken@89
    29
#include "SDL_version.h"
slouken@0
    30
#include "begin_code.h"
slouken@0
    31
slouken@0
    32
/* Set up for C function definitions, even when using C++ */
slouken@0
    33
#ifdef __cplusplus
slouken@0
    34
extern "C" {
slouken@0
    35
#endif
slouken@0
    36
slouken@89
    37
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
slouken@89
    38
*/
slouken@89
    39
#define SDL_IMAGE_MAJOR_VERSION	1
slouken@89
    40
#define SDL_IMAGE_MINOR_VERSION	2
slouken@206
    41
#define SDL_IMAGE_PATCHLEVEL	8
slouken@89
    42
slouken@89
    43
/* This macro can be used to fill a version structure with the compile-time
slouken@89
    44
 * version of the SDL_image library.
slouken@89
    45
 */
slouken@89
    46
#define SDL_IMAGE_VERSION(X)						\
slouken@89
    47
{									\
slouken@89
    48
	(X)->major = SDL_IMAGE_MAJOR_VERSION;				\
slouken@89
    49
	(X)->minor = SDL_IMAGE_MINOR_VERSION;				\
slouken@89
    50
	(X)->patch = SDL_IMAGE_PATCHLEVEL;				\
slouken@89
    51
}
slouken@89
    52
slouken@89
    53
/* This function gets the version of the dynamically linked SDL_image library.
slouken@89
    54
   it should NOT be used to fill a version structure, instead you should
slouken@89
    55
   use the SDL_IMAGE_VERSION() macro.
slouken@89
    56
 */
slouken@89
    57
extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void);
slouken@89
    58
slouken@205
    59
typedef enum
slouken@205
    60
{
slouken@205
    61
    IMG_INIT_JPG = 0x00000001,
slouken@205
    62
    IMG_INIT_PNG = 0x00000002,
slouken@226
    63
    IMG_INIT_TIF = 0x00000004
slouken@205
    64
} IMG_InitFlags;
slouken@205
    65
slouken@205
    66
/* Loads dynamic libraries and prepares them for use.  Flags should be
slouken@233
    67
   one or more flags from IMG_InitFlags OR'd together.
slouken@233
    68
   It returns the flags successfully initialized, or 0 on failure.
slouken@233
    69
 */
slouken@205
    70
extern DECLSPEC int SDLCALL IMG_Init(int flags);
slouken@205
    71
slouken@205
    72
/* Unloads libraries loaded with IMG_Init */
slouken@205
    73
extern DECLSPEC void SDLCALL IMG_Quit();
slouken@205
    74
slouken@0
    75
/* Load an image from an SDL data source.
slouken@0
    76
   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
slouken@0
    77
slouken@0
    78
   If the image format supports a transparent pixel, SDL will set the
slouken@0
    79
   colorkey for the surface.  You can enable RLE acceleration on the
slouken@0
    80
   surface afterwards by calling:
slouken@0
    81
	SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
slouken@0
    82
 */
slouken@64
    83
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type);
slouken@0
    84
/* Convenience functions */
slouken@64
    85
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
slouken@64
    86
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
slouken@0
    87
slouken@0
    88
/* Invert the alpha of a surface for use with OpenGL
slouken@4
    89
   This function is now a no-op, and only provided for backwards compatibility.
slouken@4
    90
*/
slouken@64
    91
extern DECLSPEC int SDLCALL IMG_InvertAlpha(int on);
slouken@0
    92
slouken@0
    93
/* Functions to detect a file type, given a seekable source */
couriersud@189
    94
extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src);
couriersud@189
    95
extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src);
slouken@64
    96
extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
slouken@64
    97
extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
slouken@64
    98
extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
slouken@119
    99
extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
slouken@119
   100
extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
slouken@119
   101
extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
slouken@119
   102
extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
slouken@64
   103
extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
slouken@119
   104
extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
slouken@119
   105
extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
slouken@119
   106
extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
slouken@0
   107
slouken@0
   108
/* Individual loading functions */
couriersud@189
   109
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
couriersud@189
   110
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src);
slouken@64
   111
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
slouken@64
   112
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
slouken@64
   113
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
slouken@119
   114
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
slouken@119
   115
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
slouken@119
   116
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
slouken@119
   117
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
slouken@119
   118
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
slouken@64
   119
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
slouken@119
   120
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
slouken@119
   121
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
slouken@119
   122
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
slouken@0
   123
slouken@64
   124
extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
slouken@35
   125
slouken@0
   126
/* We'll use SDL for reporting errors */
slouken@0
   127
#define IMG_SetError	SDL_SetError
slouken@0
   128
#define IMG_GetError	SDL_GetError
slouken@0
   129
slouken@0
   130
/* Ends C function definitions when using C++ */
slouken@0
   131
#ifdef __cplusplus
slouken@19
   132
}
slouken@0
   133
#endif
slouken@0
   134
#include "close_code.h"
slouken@0
   135
slouken@90
   136
#endif /* _SDL_IMAGE_H */