IMG_xxx.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 26 Sep 2018 15:19:34 -0400
changeset 587 32a18ca05935
parent 575 36e9e2255178
child 638 e3e9d7430674
permissions -rw-r--r--
pnm: Don't get into infinite loops on truncated files.
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
/* This is a generic "format not supported" image framework */
slouken@0
    23
slouken@0
    24
#include "SDL_image.h"
slouken@0
    25
slouken@0
    26
#ifdef LOAD_XXX
slouken@0
    27
slouken@0
    28
/* See if an image is contained in a data source */
slouken@0
    29
int IMG_isXXX(SDL_RWops *src)
slouken@0
    30
{
slouken@368
    31
    int start;
slouken@368
    32
    int is_XXX;
slouken@0
    33
slouken@368
    34
    if ( !src )
slouken@368
    35
        return 0;
slouken@368
    36
    start = SDL_RWtell(src);
slouken@368
    37
    is_XXX = 0;
slouken@118
    38
slouken@368
    39
    /* Detect the image here */
slouken@118
    40
slouken@368
    41
    SDL_RWseek(src, start, RW_SEEK_SET);
slouken@368
    42
    return(is_XXX);
slouken@0
    43
}
slouken@0
    44
slouken@0
    45
/* Load a XXX type image from an SDL datasource */
slouken@0
    46
SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
slouken@0
    47
{
slouken@368
    48
    int start;
slouken@368
    49
    const char *error = NULL;
slouken@368
    50
    SDL_Surface *surface = NULL;
slouken@118
    51
slouken@368
    52
    if ( !src ) {
slouken@368
    53
        /* The error message has been set in SDL_RWFromFile */
slouken@368
    54
        return NULL;
slouken@368
    55
    }
slouken@368
    56
    start = SDL_RWtell(src);
slouken@118
    57
slouken@368
    58
    /* Load the image here */
slouken@118
    59
slouken@368
    60
    if ( error ) {
slouken@368
    61
        SDL_RWseek(src, start, RW_SEEK_SET);
slouken@368
    62
        if ( surface ) {
slouken@368
    63
            SDL_FreeSurface(surface);
slouken@368
    64
            surface = NULL;
slouken@368
    65
        }
icculus@465
    66
        IMG_SetError("%s", error);
slouken@368
    67
    }
slouken@368
    68
    return surface;
slouken@0
    69
}
slouken@0
    70
slouken@0
    71
#else
slouken@0
    72
slouken@0
    73
/* See if an image is contained in a data source */
slouken@0
    74
int IMG_isXXX(SDL_RWops *src)
slouken@0
    75
{
slouken@368
    76
    return(0);
slouken@0
    77
}
slouken@0
    78
slouken@0
    79
/* Load a XXX type image from an SDL datasource */
slouken@0
    80
SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
slouken@0
    81
{
slouken@368
    82
    return(NULL);
slouken@0
    83
}
slouken@0
    84
slouken@0
    85
#endif /* LOAD_XXX */