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?

1
  • 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". Commented Jul 9, 2020 at 4:55

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.