SDL_image.h
author Sam Lantinga <slouken@lokigames.com>
Sat, 28 Apr 2001 18:24:37 +0000
changeset 35 4b1f174486fa
parent 26 d51719e1b5d9
child 45 45736a3044c0
permissions -rw-r--r--
Date: Tue, 24 Apr 2001 15:26:53 +0200 (MET DST)
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Subject: XPM patch to SDL_image

A couple of people have requested an interface to SDL_image for loading
SDL images directly from #included XPM files in the C source.
Writing a separate loader for this would be silly as the code in SDL_image
already does the XPM parsing, so I added a new call to the SDL_image API:

SDL_Surface *IMG_ReadXPMFromArray(char **xpm);

which does the obvious thing. As a bonus, the code got a little cleaner as
well. (We probably need to increase the minor .so-version number since the
interface got changed but I didn't do so in my patch.)

We should perhaps include the rgb.txt colour name database as well, since
it's quite small (~13K in binary form), but I haven't made up my mind

Cheers,

Mattias
slouken@0
     1
/*
slouken@0
     2
    IMGLIB:  An example image loading library for use with SDL
slouken@0
     3
    Copyright (C) 1999  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This program is free software; you can redistribute it and/or modify
slouken@0
     6
    it under the terms of the GNU General Public License as published by
slouken@0
     7
    the Free Software Foundation; either version 2 of the License, or
slouken@0
     8
    (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This program is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
slouken@0
    13
    GNU General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU General Public License
slouken@0
    16
    along with this program; if not, write to the Free Software
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@0
    20
    5635-34 Springhouse Dr.
slouken@0
    21
    Pleasanton, CA 94588 (USA)
slouken@0
    22
    slouken@devolution.com
slouken@0
    23
*/
slouken@0
    24
slouken@0
    25
/* A simple library to load images of various formats as SDL surfaces */
slouken@0
    26
slouken@0
    27
#ifndef _IMG_h
slouken@0
    28
#define _IMG_h
slouken@0
    29
slouken@0
    30
#include "SDL.h"
slouken@0
    31
#include "begin_code.h"
slouken@0
    32
slouken@0
    33
/* Set up for C function definitions, even when using C++ */
slouken@0
    34
#ifdef __cplusplus
slouken@0
    35
extern "C" {
slouken@0
    36
#endif
slouken@0
    37
slouken@0
    38
/* Load an image from an SDL data source.
slouken@0
    39
   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
slouken@0
    40
slouken@0
    41
   If the image format supports a transparent pixel, SDL will set the
slouken@0
    42
   colorkey for the surface.  You can enable RLE acceleration on the
slouken@0
    43
   surface afterwards by calling:
slouken@0
    44
	SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
slouken@0
    45
 */
slouken@0
    46
extern DECLSPEC SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc,
slouken@0
    47
					      char *type);
slouken@0
    48
/* Convenience functions */
slouken@0
    49
extern DECLSPEC SDL_Surface *IMG_Load(const char *file);
slouken@0
    50
extern DECLSPEC SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc);
slouken@0
    51
slouken@0
    52
/* Invert the alpha of a surface for use with OpenGL
slouken@4
    53
   This function is now a no-op, and only provided for backwards compatibility.
slouken@4
    54
*/
slouken@0
    55
extern DECLSPEC int IMG_InvertAlpha(int on);
slouken@0
    56
slouken@0
    57
/* Functions to detect a file type, given a seekable source */
slouken@0
    58
extern DECLSPEC int IMG_isBMP(SDL_RWops *src);
slouken@24
    59
extern DECLSPEC int IMG_isPNM(SDL_RWops *src);
slouken@7
    60
extern DECLSPEC int IMG_isXPM(SDL_RWops *src);
slouken@26
    61
extern DECLSPEC int IMG_isXCF(SDL_RWops *src);
slouken@0
    62
extern DECLSPEC int IMG_isPCX(SDL_RWops *src);
slouken@0
    63
extern DECLSPEC int IMG_isGIF(SDL_RWops *src);
slouken@0
    64
extern DECLSPEC int IMG_isJPG(SDL_RWops *src);
slouken@0
    65
extern DECLSPEC int IMG_isTIF(SDL_RWops *src);
slouken@0
    66
extern DECLSPEC int IMG_isPNG(SDL_RWops *src);
slouken@0
    67
slouken@0
    68
/* Individual loading functions */
slouken@0
    69
extern DECLSPEC SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src);
slouken@24
    70
extern DECLSPEC SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src);
slouken@7
    71
extern DECLSPEC SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src);
slouken@26
    72
extern DECLSPEC SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src);
slouken@0
    73
extern DECLSPEC SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src);
slouken@0
    74
extern DECLSPEC SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src);
slouken@0
    75
extern DECLSPEC SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src);
slouken@0
    76
extern DECLSPEC SDL_Surface *IMG_LoadTIF_RW(SDL_RWops *src);
slouken@0
    77
extern DECLSPEC SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src);
slouken@0
    78
extern DECLSPEC SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src);
slouken@0
    79
slouken@35
    80
extern DECLSPEC SDL_Surface *IMG_ReadXPMFromArray(char **xpm);
slouken@35
    81
slouken@0
    82
/* We'll use SDL for reporting errors */
slouken@0
    83
#define IMG_SetError	SDL_SetError
slouken@0
    84
#define IMG_GetError	SDL_GetError
slouken@0
    85
slouken@0
    86
/* Ends C function definitions when using C++ */
slouken@0
    87
#ifdef __cplusplus
slouken@19
    88
}
slouken@0
    89
#endif
slouken@0
    90
#include "close_code.h"
slouken@0
    91
slouken@0
    92
#endif /* _IMG_h */