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?
stbi_load
returnsNULL
. 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".