我正在尝试将一些带有 stb_image 的图像加载到unsigned char*
. 代码如下:
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
namespace rhino {
Texture::Texture(const std::string& file) {
stbi_set_flip_vertically_on_load(1);
buffer = stbi_load(file.c_str(), &width, &height, &bpp, 4);
...
、和变量在类buffer
中声明。调用后,和为0。我确定文件路径是正确的,但即使我输入了错误的路径,也会出现相同的结果。我不知道如果发生错误,stbi_image 是否应该在控制台上打印一些东西,但那里没有打印任何文本。bpp
width
height
Texture
stbi_load
width
height
bpp
[编辑] 有人真的知道如果 stb_image 无法读取图像会发生什么吗?