【发布时间】:2017-09-03 04:47:26
【问题描述】:
我正在尝试使用stbi_load() 加载纹理。这是我的代码:
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);
当我运行程序时,它显示Cannot load texture。我不知道怎么了。我确信文件名是一个有效的路径,因为当我写的时候:
std::ifstream infile(fileName);
if (infile.good())
{
cout << "Good" << endl;
}
else
{
cout << "Not good" << endl;
}
它产生Good。谁能告诉我这段代码有什么问题导致imgData 成为NULL(如果有人想知道,图像是*.jpg 文件)。任何帮助将不胜感激!
编辑:我运行了stbi_failure_reason(),它返回了progressive jpeg。这是什么意思?
【问题讨论】:
-
您是否尝试过在调试器中单步执行以查看失败的位置/原因?
-
@tkausl 不,但就在刚才,我运行了
stbi_failure_reason(),它返回了progressive jpeg。这是什么意思?
标签: c++