SDL_image.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 01 Jan 2017 18:50:51 -0800
changeset 496 6332f9425dcc
parent 495 f4d6370dac36
child 502 7f374d902c16
permissions -rw-r--r--
Updated copyright for 2017
slouken@0
     1
/*
slouken@280
     2
  SDL_image:  An example image loading library for use with SDL
slouken@496
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@280
     5
  This software is provided 'as-is', without any express or implied
slouken@280
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@280
     7
  arising from the use of this software.
slouken@0
     8
slouken@280
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@280
    10
  including commercial applications, and to alter it and redistribute it
slouken@280
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@280
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@280
    14
     claim that you wrote the original software. If you use this software
slouken@280
    15
     in a product, an acknowledgment in the product documentation would be
slouken@280
    16
     appreciated but is not required.
slouken@280
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@280
    18
     misrepresented as being the original software.
slouken@280
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@0
    22
/* A simple library to load images of various formats as SDL surfaces */
slouken@0
    23
slouken@495
    24
#ifndef SDL_IMAGE_H_
slouken@495
    25
#define SDL_IMAGE_H_
slouken@0
    26
slouken@0
    27
#include "SDL.h"
slouken@89
    28
#include "SDL_version.h"
slouken@0
    29
#include "begin_code.h"
slouken@0
    30
slouken@0
    31
/* Set up for C function definitions, even when using C++ */
slouken@0
    32
#ifdef __cplusplus
slouken@0
    33
extern "C" {
slouken@0
    34
#endif
slouken@0
    35
slouken@89
    36
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
slouken@89
    37
*/
slouken@368
    38
#define SDL_IMAGE_MAJOR_VERSION 2
slouken@368
    39
#define SDL_IMAGE_MINOR_VERSION 0
slouken@487
    40
#define SDL_IMAGE_PATCHLEVEL    1
slouken@89
    41
slouken@89
    42
/* This macro can be used to fill a version structure with the compile-time
slouken@89
    43
 * version of the SDL_image library.
slouken@89
    44
 */
slouken@368
    45
#define SDL_IMAGE_VERSION(X)                        \
slouken@368
    46
{                                                   \
slouken@368
    47
    (X)->major = SDL_IMAGE_MAJOR_VERSION;           \
slouken@368
    48
    (X)->minor = SDL_IMAGE_MINOR_VERSION;           \
slouken@368
    49
    (X)->patch = SDL_IMAGE_PATCHLEVEL;              \
slouken@89
    50
}
slouken@89
    51
slouken@89
    52
/* This function gets the version of the dynamically linked SDL_image library.
slouken@89
    53
   it should NOT be used to fill a version structure, instead you should
slouken@89
    54
   use the SDL_IMAGE_VERSION() macro.
slouken@89
    55
 */
slouken@89
    56
extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void);
slouken@89
    57
slouken@205
    58
typedef enum
slouken@205
    59
{
slouken@205
    60
    IMG_INIT_JPG = 0x00000001,
slouken@205
    61
    IMG_INIT_PNG = 0x00000002,
slouken@278
    62
    IMG_INIT_TIF = 0x00000004,
slouken@278
    63
    IMG_INIT_WEBP = 0x00000008
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@246
    73
extern DECLSPEC void SDLCALL IMG_Quit(void);
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@368
    81
    SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
slouken@0
    82
 */
slouken@320
    83
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const 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@393
    88
#if SDL_VERSION_ATLEAST(2,0,0)
slouken@320
    89
/* Load an image directly into a render texture.
slouken@320
    90
 */
slouken@320
    91
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file);
slouken@320
    92
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc);
slouken@320
    93
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type);
slouken@393
    94
#endif /* SDL 2.0 */
slouken@320
    95
slouken@0
    96
/* Functions to detect a file type, given a seekable source */
couriersud@189
    97
extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src);
couriersud@189
    98
extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src);
slouken@64
    99
extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
slouken@64
   100
extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
slouken@64
   101
extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
slouken@119
   102
extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
slouken@119
   103
extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
slouken@119
   104
extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
slouken@119
   105
extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
slouken@64
   106
extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
slouken@119
   107
extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
slouken@119
   108
extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
slouken@119
   109
extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
slouken@278
   110
extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src);
slouken@0
   111
slouken@0
   112
/* Individual loading functions */
couriersud@189
   113
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
couriersud@189
   114
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src);
slouken@64
   115
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
slouken@64
   116
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
slouken@64
   117
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
slouken@119
   118
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
slouken@119
   119
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
slouken@119
   120
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
slouken@119
   121
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
slouken@119
   122
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
slouken@64
   123
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
slouken@119
   124
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
slouken@119
   125
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
slouken@119
   126
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
slouken@278
   127
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src);
slouken@0
   128
slouken@64
   129
extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
slouken@35
   130
slouken@391
   131
/* Individual saving functions */
slouken@391
   132
extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file);
slouken@391
   133
extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
slouken@391
   134
slouken@0
   135
/* We'll use SDL for reporting errors */
slouken@368
   136
#define IMG_SetError    SDL_SetError
slouken@368
   137
#define IMG_GetError    SDL_GetError
slouken@0
   138
slouken@0
   139
/* Ends C function definitions when using C++ */
slouken@0
   140
#ifdef __cplusplus
slouken@19
   141
}
slouken@0
   142
#endif
slouken@0
   143
#include "close_code.h"
slouken@0
   144
slouken@495
   145
#endif /* SDL_IMAGE_H_ */