3

I am loading a png file using stb_image_load. The code looks something like

stbi_uc* pixels = stbi_load("textures/viking_room.png", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
...

if (stbi_failure_reason()) std::cout << stbi_failure_reason();

if (!pixels) throw std::runtime_error("failed to load texture image!");

Now stbi_failure_reason() return no SOI but pixels is not empty and loads the texture perfectly. The first result on github about this was about malformed png headers, so I checked using pngcheck, but it says that the png file is OK.

Any idea why this might be happening? I've also had trouble loading this image However it works with other images, is there any way I can avoid this in future?

Pranav Nachnekar
  • 115
  • 1
  • 10
  • 3
    If I read the documentation correctly the only time you should be checking for an error is if `stbi_load` returns `NULL`. It sounds like it is returning a valid pointer which indicates no error. If you read the code it checks for different file types until it finds one that matches. JPEG is checked before PNG and that is why the message is set to "no SOI". – Retired Ninja Jul 09 '20 at 04:55

1 Answers1

1

There was an issue opened 787 for this and was fixed on a newer version (2.27)

pedro_bb7
  • 1,601
  • 3
  • 12
  • 28