2014-03-06 107 views
0

我試圖在FreeImage中加載.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 
+0

見'FreeImage_SetOutputMessage'文檔,並使用它,也許你會收到一條錯誤消息。你也可能錯過了對FreeImage_Initialise的調用。 – user2802841

回答

0

你可能會缺少FreeImage_Initialise通話(除非您使用的是DLL)。

0

有時FreeImage的doesntmanage從FreeImage_GetFileType

閱讀FREE_IMAGE_FORMAT

故recomended檢查FIF的有效性,如果FIF == FIF_UNKNOWN使用FreeImage_GetFIFFromFilename