diff options
| author | raysan5 <raysan5@gmail.com> | 2014-07-23 00:06:24 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2014-07-23 00:06:24 +0200 |
| commit | 0b03431c95c3c348aa686c1a3df68a51bd7761a6 (patch) | |
| tree | c34f72424d76454a63f0db18f4834623c525b72a /src/textures.c | |
| parent | 5e2e9aa23e1fcbc78395443a4b0f83404b5557f8 (diff) | |
| download | raylib-0b03431c95c3c348aa686c1a3df68a51bd7761a6.tar.gz raylib-0b03431c95c3c348aa686c1a3df68a51bd7761a6.zip | |
Update to version 1.1.1
Check CHANGELOG for a detailed list of changes
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/textures.c b/src/textures.c index a21dd4bf..4bd6378d 100644 --- a/src/textures.c +++ b/src/textures.c @@ -100,26 +100,30 @@ Image LoadImage(const char *fileName) // Force loading to 4 components (RGBA) byte *imgData = stbi_load(fileName, &imgWidth, &imgHeight, &imgBpp, 4); - // Convert array to pixel array for working convenience - image.pixels = (Color *)malloc(imgWidth * imgHeight * sizeof(Color)); - - int pix = 0; - - for (int i = 0; i < (imgWidth * imgHeight * 4); i += 4) + if (imgData != NULL) { - image.pixels[pix].r = imgData[i]; - image.pixels[pix].g = imgData[i+1]; - image.pixels[pix].b = imgData[i+2]; - image.pixels[pix].a = imgData[i+3]; - pix++; + // Convert array to pixel array for working convenience + image.pixels = (Color *)malloc(imgWidth * imgHeight * sizeof(Color)); + + int pix = 0; + + for (int i = 0; i < (imgWidth * imgHeight * 4); i += 4) + { + image.pixels[pix].r = imgData[i]; + image.pixels[pix].g = imgData[i+1]; + image.pixels[pix].b = imgData[i+2]; + image.pixels[pix].a = imgData[i+3]; + pix++; + } + + stbi_image_free(imgData); + + image.width = imgWidth; + image.height = imgHeight; + + TraceLog(INFO, "[%s] Image loaded successfully", fileName); } - - stbi_image_free(imgData); - - image.width = imgWidth; - image.height = imgHeight; - - TraceLog(INFO, "[%s] Image loaded successfully", fileName); + else TraceLog(WARNING, "[%s] Image could not be loaded", fileName); } else if (strcmp(GetExtension(fileName),"dds") == 0) { |
