c++ - DevIL 错误 1290。我该如何解决?

标签 c++ devil

我想将图像加载到我的应用程序中,但出现错误: http://img510.imageshack.us/img510/5814/blad07864.png

这是这个应用程序的代码:

#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/

你能帮帮我吗?

最佳答案

根据 this post , 1290 表示找不到图像路径。尝试使用绝对文件路径,看看它是否可以加载。

关于c++ - DevIL 错误 1290。我该如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7947243/

相关文章:

c++ - 模板 :Function template specializations:Template argument deduction: -->can any one tell some more examples for this statement?

c++ - 代码中没有任何 STL 的 STL 错误

c++ - 将 OpenCV 图像数据类型转换为 Devil 图像格式,反之亦然

c++ - 使用 OpenGL 和 DevIL 调用 glTextureParameteri 时发生访问冲突

C++,如何加载图像和计算某些颜色的像素

c++ - 如何确保在关闭 fstream 之前将数据写入磁盘?

c++ - 未使用的静态对象如何初始化?

c++ - UWP 在 InitializeComponent() 处崩溃 [C++]

c++ - g++ 与 DevIL : unable to link

c++ - 如何从原始数据加载 devIL 图像