SDL_image.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Mar 2018 09:32:34 -0800
changeset 575 36e9e2255178
parent 564 245e1a073937
child 615 923efa629d1c
permissions -rw-r--r--
Updated copyright for 2018
slouken@0
     1
/*
slouken@280
     2
  SDL_image:  An example image loading library for use with SDL
slouken@575
     3
  Copyright (C) 1997-2018 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@564
    40
#define SDL_IMAGE_PATCHLEVEL    3
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@516
    52
/**
slouken@516
    53
 *  This is the version number macro for the current SDL_image version.
slouken@516
    54
 */
slouken@516
    55
#define SDL_IMAGE_COMPILEDVERSION \
slouken@516
    56
    SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL)
slouken@516
    57
slouken@516
    58
/**
slouken@516
    59
 *  This macro will evaluate to true if compiled with SDL_image at least X.Y.Z.
slouken@516
    60
 */
slouken@516
    61
#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
slouken@516
    62
    (SDL_IMAGE_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
slouken@516
    63
slouken@89
    64
/* This function gets the version of the dynamically linked SDL_image library.
slouken@89
    65
   it should NOT be used to fill a version structure, instead you should
slouken@89
    66
   use the SDL_IMAGE_VERSION() macro.
slouken@89
    67
 */
slouken@89
    68
extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void);
slouken@89
    69
slouken@205
    70
typedef enum
slouken@205
    71
{
slouken@205
    72
    IMG_INIT_JPG = 0x00000001,
slouken@205
    73
    IMG_INIT_PNG = 0x00000002,
slouken@278
    74
    IMG_INIT_TIF = 0x00000004,
slouken@278
    75
    IMG_INIT_WEBP = 0x00000008
slouken@205
    76
} IMG_InitFlags;
slouken@205
    77
slouken@205
    78
/* Loads dynamic libraries and prepares them for use.  Flags should be
slouken@233
    79
   one or more flags from IMG_InitFlags OR'd together.
slouken@233
    80
   It returns the flags successfully initialized, or 0 on failure.
slouken@233
    81
 */
slouken@205
    82
extern DECLSPEC int SDLCALL IMG_Init(int flags);
slouken@205
    83
slouken@205
    84
/* Unloads libraries loaded with IMG_Init */
slouken@246
    85
extern DECLSPEC void SDLCALL IMG_Quit(void);
slouken@205
    86
slouken@0
    87
/* Load an image from an SDL data source.
slouken@0
    88
   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
slouken@0
    89
slouken@0
    90
   If the image format supports a transparent pixel, SDL will set the
slouken@0
    91
   colorkey for the surface.  You can enable RLE acceleration on the
slouken@0
    92
   surface afterwards by calling:
slouken@368
    93
    SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
slouken@0
    94
 */
slouken@320
    95
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type);
slouken@0
    96
/* Convenience functions */
slouken@64
    97
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
slouken@64
    98
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
slouken@0
    99
slouken@393
   100
#if SDL_VERSION_ATLEAST(2,0,0)
slouken@320
   101
/* Load an image directly into a render texture.
slouken@320
   102
 */
slouken@320
   103
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file);
slouken@320
   104
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc);
slouken@320
   105
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type);
slouken@393
   106
#endif /* SDL 2.0 */
slouken@320
   107
slouken@0
   108
/* Functions to detect a file type, given a seekable source */
couriersud@189
   109
extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src);
couriersud@189
   110
extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src);
slouken@64
   111
extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
slouken@64
   112
extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
slouken@64
   113
extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
slouken@119
   114
extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
slouken@119
   115
extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
slouken@119
   116
extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
slouken@119
   117
extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
slouken@524
   118
extern DECLSPEC int SDLCALL IMG_isSVG(SDL_RWops *src);
slouken@64
   119
extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
slouken@119
   120
extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
slouken@119
   121
extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
slouken@119
   122
extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
slouken@278
   123
extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src);
slouken@0
   124
slouken@0
   125
/* Individual loading functions */
couriersud@189
   126
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
couriersud@189
   127
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src);
slouken@64
   128
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
slouken@64
   129
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
slouken@64
   130
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
slouken@119
   131
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
slouken@119
   132
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
slouken@119
   133
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
slouken@119
   134
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
slouken@524
   135
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSVG_RW(SDL_RWops *src);
slouken@119
   136
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
slouken@64
   137
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
slouken@119
   138
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
slouken@119
   139
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
slouken@119
   140
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
slouken@278
   141
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src);
slouken@0
   142
slouken@64
   143
extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
slouken@35
   144
slouken@391
   145
/* Individual saving functions */
slouken@391
   146
extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file);
slouken@391
   147
extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
slouken@502
   148
extern DECLSPEC int SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality);
slouken@502
   149
extern DECLSPEC int SDLCALL IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality);
slouken@391
   150
slouken@0
   151
/* We'll use SDL for reporting errors */
slouken@368
   152
#define IMG_SetError    SDL_SetError
slouken@368
   153
#define IMG_GetError    SDL_GetError
slouken@0
   154
slouken@0
   155
/* Ends C function definitions when using C++ */
slouken@0
   156
#ifdef __cplusplus
slouken@19
   157
}
slouken@0
   158
#endif
slouken@0
   159
#include "close_code.h"
slouken@0
   160
slouken@495
   161
#endif /* SDL_IMAGE_H_ */