![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| int | readppm (char *name, int *xres, int *yres, unsigned char **imgdata) |
| int readppm | ( | char * | name, |
| int * | xres, | ||
| int * | yres, | ||
| unsigned char ** | imgdata | ||
| ) |
Definition at line 91 of file ppm.cpp.
References getint(), IMAGEBADFILE, IMAGENOERR, IMAGEREADERR, IMAGEUNSUP, and rt_getmem().
Referenced by readimage().
{
char data[200];
FILE * ifp;
int i, bytesread;
int datasize;
ifp=fopen(name, "r");
if (ifp==NULL) {
return IMAGEBADFILE; /* couldn't open the file */
}
fscanf(ifp, "%s", data);
if (strcmp(data, "P6")) {
fclose(ifp);
return IMAGEUNSUP; /* not a format we support */
}
*xres=getint(ifp);
*yres=getint(ifp);
i=getint(ifp); /* eat the maxval number */
fread(&i, 1, 1, ifp); /* eat the newline */
datasize = 3 * (*xres) * (*yres);
*imgdata=(unsigned char *)rt_getmem(datasize);
bytesread=fread(*imgdata, 1, datasize, ifp);
fclose(ifp);
if (bytesread != datasize)
return IMAGEREADERR;
return IMAGENOERR;
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.