IMG_xxx.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 04 Feb 2006 22:26:04 +0000
changeset 118 c5e736a47ad2
parent 117 e613cf987897
child 121 1bf9c0c87374
permissions -rw-r--r--
If there's an error loading an image, seek back to the start of the image.
     1 /*
     2     SDL_image:  An example image loading library for use with SDL
     3     Copyright (C) 1999-2004 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /* $Id$ */
    24 
    25 /* This is a generic "format not supported" image framework */
    26 
    27 #include <stdio.h>
    28 
    29 #include "SDL_image.h"
    30 
    31 #ifdef LOAD_XXX
    32 
    33 /* See if an image is contained in a data source */
    34 int IMG_isXXX(SDL_RWops *src)
    35 {
    36 	int start;
    37 	int is_XXX;
    38 
    39 	start = SDL_RWtell(src);
    40 	is_XXX = 0;
    41 
    42 	/* Detect the image here */
    43 
    44 	SDL_RWseek(src, start, SEEK_SET);
    45 	return(is_XXX);
    46 }
    47 
    48 /* Load a XXX type image from an SDL datasource */
    49 SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
    50 {
    51 	int start;
    52 	const char *error = NULL;
    53 	SDL_Surface *surface = NULL;
    54 
    55 	if ( !src ) {
    56 		/* The error message has been set in SDL_RWFromFile */
    57 		return NULL;
    58 	}
    59 	start = SDL_RWtell(src);
    60 
    61 	/* Load the image here */
    62 
    63 	if ( error ) {
    64 		SDL_RWseek(src, start, SEEK_SET);
    65 		if ( surface ) {
    66 			SDL_FreeSurface(surface);
    67 			surface = NULL;
    68 		}
    69 		IMG_SetError(error);
    70 	}
    71 	return surface;
    72 }
    73 
    74 #else
    75 
    76 /* See if an image is contained in a data source */
    77 int IMG_isXXX(SDL_RWops *src)
    78 {
    79 	return(0);
    80 }
    81 
    82 /* Load a XXX type image from an SDL datasource */
    83 SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
    84 {
    85 	return(NULL);
    86 }
    87 
    88 #endif /* LOAD_XXX */