static int LoadImage(char *path, Image * img, Pixel color) { char *extn; extn = strrchr(path, '.'); #ifndef NO_XPM_SUPPORT if (strcasecmp(extn, ".xpm") == 0) LoadXPMImage(path, img, color); #endif /* NO_XPM_SUPPORT */ #ifndef NO_PNG_SUPPORT if (strcasecmp(extn, ".png") == 0) LoadPNGImage(path, img); #endif /* NO_PNG_SUPPORT */ if (img->type != IMAGE_TYPE_NONE) return (TRUE); return (FALSE); }
/** Load an image from the specified file. */ ImageNode *LoadImage(const char *fileName, int width, int height, char preserveAspect) { unsigned nameLength; ImageNode *result = NULL; if(!fileName) { return result; } nameLength = strlen(fileName); if(JUNLIKELY(nameLength == 0)) { return result; } /* Attempt to load the file as a PNG image. */ #ifdef USE_PNG if(nameLength >= 4 && !StrCmpNoCase(&fileName[nameLength - 4], ".png")) { result = LoadPNGImage(fileName); if(result) { return result; } } #endif /* Attempt to load the file as a JPEG image. */ #ifdef USE_JPEG if( (nameLength >= 4 && !StrCmpNoCase(&fileName[nameLength - 4], ".jpg")) || (nameLength >= 5 && !StrCmpNoCase(&fileName[nameLength - 5], ".jpeg"))) { result = LoadJPEGImage(fileName, width, height); if(result) { return result; } } #endif /* Attempt to load the file as an SVG image. */ #if defined USE_RSVG || defined USE_NANOSVG if(nameLength >= 4 && !StrCmpNoCase(&fileName[nameLength - 4], ".svg")) { result = LoadSVGImage(fileName, width, height, preserveAspect); if(result) { return result; } } #endif /* Attempt to load the file as an XPM image. */ #ifdef USE_XPM if(nameLength >= 4 && !StrCmpNoCase(&fileName[nameLength - 4], ".xpm")) { result = LoadXPMImage(fileName); if(result) { return result; } } #endif /* Attempt to load the file as an XBM image. */ #ifdef USE_XBM if(nameLength >= 4 && !StrCmpNoCase(&fileName[nameLength - 4], ".xbm")) { result = LoadXBMImage(fileName); if(result) { return result; } } #endif /* Attempt to load a PNG, JPEG, GIf, TGA, BMP, PNM, PSD or PIC image. */ #ifdef USE_STB_IMAGE result = LoadstbImage(fileName); #endif return result; }