~ubuntu-branches/ubuntu/karmic/sdl-image1.2/karmic

« back to all changes in this revision

Viewing changes to IMG.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2005-02-23 10:44:58 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050223104458-2zcmjsl6rd8ad9uw
Tags: 1.2.4-1
* New upstream release
* debian/copyright: Fixed header for license text (Closes: #290199)
* Updated config.guess and config.sub (Closes: #267493)
* debian/rules: Use dh_installman instead of dh_installmanpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    SDL_image:  An example image loading library for use with SDL
3
 
    Copyright (C) 1999, 2000, 2001  Sam Lantinga
 
3
    Copyright (C) 1999-2004 Sam Lantinga
4
4
 
5
5
    This library is free software; you can redistribute it and/or
6
6
    modify it under the terms of the GNU Library General Public
20
20
    slouken@libsdl.org
21
21
*/
22
22
 
23
 
/* $Id: IMG.c,v 1.12 2003/02/09 19:20:10 slouken Exp $ */
 
23
/* $Id: IMG.c,v 1.15 2004/01/04 17:33:01 slouken Exp $ */
24
24
 
25
25
/* A simple library to load images of various formats as SDL surfaces */
26
26
 
39
39
        SDL_Surface *(*load)(SDL_RWops *src);
40
40
} supported[] = {
41
41
        /* keep magicless formats first */
42
 
        { "TGA", 0,         IMG_LoadTGA_RW },
 
42
        { "TGA", NULL,      IMG_LoadTGA_RW },
43
43
        { "BMP", IMG_isBMP, IMG_LoadBMP_RW },
44
44
        { "PNM", IMG_isPNM, IMG_LoadPNM_RW }, /* P[BGP]M share code */
45
45
        { "XPM", IMG_isXPM, IMG_LoadXPM_RW },
52
52
        { "PNG", IMG_isPNG, IMG_LoadPNG_RW }
53
53
};
54
54
 
 
55
const SDL_version *IMG_Linked_Version(void)
 
56
{
 
57
        static SDL_version linked_version;
 
58
        SDL_IMAGE_VERSION(&linked_version);
 
59
        return(&linked_version);
 
60
}
 
61
 
55
62
/* Load an image from a file */
56
63
SDL_Surface *IMG_Load(const char *file)
57
64
{
58
65
    SDL_RWops *src = SDL_RWFromFile(file, "rb");
59
66
    char *ext = strrchr(file, '.');
60
 
    if(ext)
61
 
        ext++;
 
67
    if(ext) {
 
68
        ext++;
 
69
    }
 
70
    if(!src) {
 
71
        /* The error message has been set in SDL_RWFromFile */
 
72
        return NULL;
 
73
    }
62
74
    return IMG_LoadTyped_RW(src, 1, ext);
63
75
}
64
76
 
89
101
 
90
102
        /* Make sure there is something to do.. */
91
103
        if ( src == NULL ) {
 
104
                IMG_SetError("Passed a NULL data source");
92
105
                return(NULL);
93
106
        }
94
107