I'm trying to load a texture using stbi_load()
. Here's my code:
int width, height, numComponents;
unsigned char* imgData = stbi_load(fileName.c_str(), &width, &height, &numComponents, 4);
if (imgData == NULL)
cout << "Cannot load texture" << endl;
//some code
//free
stbi_image_free(imgData);
And when I run the program, it says Cannot load texture
. I don't know what's wrong. I am sure that the filename is a valid path, because when I write:
std::ifstream infile(fileName);
if (infile.good())
{
cout << "Good" << endl;
}
else
{
cout << "Not good" << endl;
}
It produces Good
. Can someone tell me what is wrong with this code that causes imgData
to be NULL
(The image is a *.jpg
file, if anybody was wondering). Any help would be highly appreciated!
Edit : I ran stbi_failure_reason()
and it returned progressive jpeg
. What does this mean ?
So it turns out the answer was really easy. If you read from this website : https://gist.github.com/roxlu/3077861
You'll see that stb_image
doesn't support progressive JPEG
image format (which I didn't even knew existed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With