Results 1 to 9 of 9

Thread: I can't load image using devil library why ?

  1. #1
    Member Newbie
    Join Date
    Feb 2011
    Posts
    37

    I can't load image using devil library why ?

    Why I can't load image using devil library ?

    Code :
            ilInit(); /* Initialization of DevIL */
    	ilGenImages(1, &texid); /* Generation of one image name */
    	ilBindImage(texid); /* Binding of image name */
    	success = ilLoadImage(TEXT("C:/Users/TEST/Desktop/nehe.bmp")); /* Loading of image "image.jpg" */
    	if (success == IL_FALSE) 
    	{
    			ILenum error;
    			error = ilGetError();
    			MessageBox(NULL,TEXT("error"),TEXT("error"),MB_OK | MB_ICONINFORMATION);
    	}

    It gives me messagebox with text 'error' why ?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: I can't load image using devil library why ?

    It gives me messagebox with text 'error' why ?
    It gives you the text 'error' because that's what you had it print when an error happens. You need to look at the contents of the enumerator to know what error you actually got.

  3. #3
    Member Newbie
    Join Date
    Feb 2011
    Posts
    37

    Re: I can't load image using devil library why ?

    error 1291 - IL_INVALID_EXTENSION - but I have .bmp so it is good extension...

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: I can't load image using devil library why ?

    The image format is not bmp, as said by the error number.

    cf: http://www.shatters.net/~t00fri/DevI...EXTENSION.html

    As I can remember devil has function to let devil discovers the file type.

  5. #5
    Member Newbie
    Join Date
    Feb 2011
    Posts
    37

    Re: I can't load image using devil library why ?


  6. #6
    Member Newbie
    Join Date
    Feb 2011
    Posts
    37

    Re: I can't load image using devil library why ?

    Now I am using SDL library. This library works but images are upside-down lol ! For example point (0, 0) is upper left, not lower left - I don't know what I should do - should I accept this SDL behaviour and use SDL coordinates ?

    Here are relative topics with this issue:
    http://www.gamedev.net/topic/188170-...-question-sdl/

    http://bhsphd.spaces.live.com/blog/cns!1844003DFD14BA7D!312.entry

  7. #7
    Member Newbie
    Join Date
    Feb 2011
    Posts
    37

    Re: I can't load image using devil library why ?

    I have found solution for invert image in SDL: http://www.gribblegames.com/articles..._surfaces.html

    So the solution is to invert image:
    Code :
    int invert_image(int pitch, int height, void* image_pixels)
    {
       int index;
       void* temp_row;
       int height_div_2;
     
       temp_row = (void *)malloc(pitch);
       if(NULL == temp_row)
       {
          SDL_SetError("Not enough memory for image inversion");
          return -1;
       }
       //if height is odd, don't need to swap middle row
       height_div_2 = (int) (height * .5);
       for(index = 0; index < height_div_2; index++)    {
          //uses string.h
          memcpy((Uint8 *)temp_row,
             (Uint8 *)(image_pixels) +
             pitch * index,
             pitch);
     
          memcpy(
             (Uint8 *)(image_pixels) +
             pitch * index,
             (Uint8 *)(image_pixels) +
             pitch * (height - index-1),
             pitch);
          memcpy(
             (Uint8 *)(image_pixels) +
             pitch * (height - index-1),
             temp_row,
             pitch);
       }
       free(temp_row);
       return 0;
    }
     
    //This is the function you want to call!
    int SDL_InvertSurface(SDL_Surface* image)
    {
       if(NULL == image)
       {
          SDL_SetError("Surface is NULL");
          return -1;
       }
       return( invert_image(image->pitch, image->h,
             image->pixels) );
    }

    example usage:
    Code :
    SDL_Surface* surface;
    surface = IMG_Load(filename)
    SDL_InvertSurface(surface);
    //.........

  8. #8
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: I can't load image using devil library why ?

    BMP files are allowed to be inverted and this is signified by a negative value for height in the header; it's a legal part of the format.

    I really really do recommend using a different file format, such as TGA.

  9. #9
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    1

    Re: I can't load image using devil library why ?

    Sorry to bump oldish thread but it was the top one on google for the error.
    Wanted to say the guy was right, there is a bug in DevIL, Im using the 2008 version of DevIL now (1.7.3) and it's working fine. : )

Similar Threads

  1. Using libktx library to load ktx image
    By anilgoudar56 in forum KTX
    Replies: 2
    Last Post: 04-08-2017, 04:51 AM
  2. devIL failing to load an image
    By SaeedGH in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-23-2016, 08:09 PM
  3. DevIL to load video
    By Doctor100 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-15-2014, 04:20 AM
  4. To save an image to a file in DevIL
    By kacper546 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-02-2013, 12:59 PM
  5. Wanna a static library to load JPG image.
    By Suvcon in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-27-2002, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean