Skip to content

Commit 36f07b4

Browse files
committed
Use default number of channels in STB image loading
This fixes instances where different number of channels are available than those requested.
1 parent 5bb877d commit 36f07b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

n64graphics.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3+
#include <strings.h>
34

45
#define STBI_NO_LINEAR
56
#define STBI_NO_HDR
@@ -376,7 +377,7 @@ rgba *png2rgba(const char *png_filename, int *width, int *height)
376377
int channels = 0;
377378
int img_size;
378379

379-
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, 4);
380+
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
380381
if (!data || w <= 0 || h <= 0) {
381382
ERROR("Error loading \"%s\"\n", png_filename);
382383
return NULL;
@@ -432,15 +433,14 @@ rgba *png2rgba(const char *png_filename, int *width, int *height)
432433
return img;
433434
}
434435

435-
// save IA data to grayscale PNG file
436436
ia *png2ia(const char *png_filename, int *width, int *height)
437437
{
438438
ia *img = NULL;
439439
int w = 0, h = 0;
440440
int channels = 0;
441441
int img_size;
442442

443-
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, 2);
443+
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
444444
if (!data || w <= 0 || h <= 0) {
445445
ERROR("Error loading \"%s\"\n", png_filename);
446446
return NULL;

0 commit comments

Comments
 (0)