Additional check on file open
This commit is contained in:
parent
eee8393eb0
commit
8c1f32f2fe
1 changed files with 14 additions and 11 deletions
|
@ -192,19 +192,22 @@ Image LoadImage(const char *fileName)
|
||||||
|
|
||||||
FILE *imFile = fopen(fileName, "rb");
|
FILE *imFile = fopen(fileName, "rb");
|
||||||
|
|
||||||
// NOTE: Using stb_image to load images (Supports: BMP, TGA, PNG, JPG, ...)
|
if (imFile != NULL)
|
||||||
image.data = stbi_load_from_file(imFile, &imgWidth, &imgHeight, &imgBpp, 0);
|
{
|
||||||
|
// NOTE: Using stb_image to load images (Supports: BMP, TGA, PNG, JPG, ...)
|
||||||
|
image.data = stbi_load_from_file(imFile, &imgWidth, &imgHeight, &imgBpp, 0);
|
||||||
|
|
||||||
fclose(imFile);
|
fclose(imFile);
|
||||||
|
|
||||||
image.width = imgWidth;
|
image.width = imgWidth;
|
||||||
image.height = imgHeight;
|
image.height = imgHeight;
|
||||||
image.mipmaps = 1;
|
image.mipmaps = 1;
|
||||||
|
|
||||||
if (imgBpp == 1) image.format = UNCOMPRESSED_GRAYSCALE;
|
if (imgBpp == 1) image.format = UNCOMPRESSED_GRAYSCALE;
|
||||||
else if (imgBpp == 2) image.format = UNCOMPRESSED_GRAY_ALPHA;
|
else if (imgBpp == 2) image.format = UNCOMPRESSED_GRAY_ALPHA;
|
||||||
else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8;
|
else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8;
|
||||||
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
|
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if defined(SUPPORT_FILEFORMAT_HDR)
|
#if defined(SUPPORT_FILEFORMAT_HDR)
|
||||||
else if (IsFileExtension(fileName, ".hdr"))
|
else if (IsFileExtension(fileName, ".hdr"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue