2011-10-30 33 views
0

我想加載圖像到我的應用程序,但我有一個錯誤: http://img510.imageshack.us/img510/5814/blad07864.pngDevIL錯誤1290.我該如何解決它?

這是此應用程序的代碼:

#include <stdio.h> 
#include <stdlib.h> 

#undef _UNICODE 
#include "il.h" 

#pragma comment(lib, "DevIL.lib") 

// Wow. DevIL is amazing. 

// From http://gpwiki.org/index.php/DevIL:Tutorials:Basics 

// The library consists of three sub-libraries: 
// * IL - main DevIL library. It allows you to load and save images to files. Every function in this library have 'il' prefixed to their name. 
// * ILU - this library contains functions for altering images. Every function in this library have 'ilu' prefixed to their name. 
// * ILUT - this library connects DevIL with OpenGL. Every function in this library have 'ilut' prefixed to their name. 

int main() 
{ 
    ilInit(); 
    printf("DevIL has been initialized\n"); 

    // Loading an image 
    ILboolean result = ilLoadImage("tex1.png") ; 

    if(result == true) 
    { 
    printf("the image loaded successfully\n"); 
    } 
    else 
    { 
    printf("The image failed to load\n") ; 

    ILenum err = ilGetError() ; 
    printf("the error %d\n", err); 
    printf("string is %s\n", ilGetString(err)); 
    } 

    int size = ilGetInteger(IL_IMAGE_SIZE_OF_DATA) ; 
    printf("Data size: %d\n", size); 
    ILubyte * bytes = ilGetData() ; 

    for(int i = 0 ; i < size; i++) 
    { 
    // see we should see the byte data of the image now. 
    printf("%d\n", bytes[ i ]); 
    } 
} 

我發現從這個網站代碼:http://bobobobo.wordpress.com/2009/03/02/how-to-load-a-png-image-in-c/

你能幫我嗎?

回答

2

根據this post,1290表示沒有找到圖像路徑。嘗試使用絕對文件路徑,看看它是否可以加載。

相關問題