我试图在.png和.DDS文件中加载FreeImage,但是宽度和高度总是为零。
#include <stdio.h>
#include<stdlib.h>
#include <FreeImage.h>
int main(void){
const char* path = "Signal.png";
printf("Loading image %s\n", path);
FIBITMAP* image = FreeImage_Load(FreeImage_GetFileType(path), path, 0);
unsigned int w = FreeImage_GetWidth(image);
unsigned int h = FreeImage_GetHeight(image);
printf("Width: %u Height: %u\n", w, h);
}输出:
Loading image Signal.png
Width: 0 Height: 0发布于 2014-03-06 23:39:58
您可能缺少对FreeImage_Initialise的调用(除非您正在使用DLL)。
发布于 2015-09-21 17:26:16
有时,空闲映像无法从FREE_IMAGE_FORMAT中读取FreeImage_GetFileType
因此,我们建议检查fif的有效性,如果fif == FIF_UNKNOWN使用FreeImage_GetFIFFromFilename。
https://stackoverflow.com/questions/22238129
复制相似问题