Menu

#49 I can't load PNG

open
nobody
None
5
2010-04-21
2010-04-21
Anonymous
No

Every time I run a simple code using ilLoadImage I always get "IL_INVALID_EXTENSION"
ObsThe path of the image is wright.
This is the code:
ilInit();
ILboolean result = ilLoadImage( "C:\\map.png" ) ;

I'm using mingw.

Discussion

  • Matěj Týč

    Matěj Týč - 2010-04-21

    Hello, thank you for your feedback.
    Which DevIL version do you use?
    Could you try to use the latest tarball (= the prerelease)?
    Try to run 'make check' after configure and if something goes wrong (either test fails or the lib doesn't work), attach the config.log file (it is created by the configure script)
    Then set your env variables
    IL_LOGFILE=my-logfile.log IL_LOGLEVEL=4
    and attach the log file.
    Regards,
    Matej

     
  • Anonymous

    Anonymous - 2011-07-05

    have you tried the following code contained in the manual to c if it works
    -------------------
    #include<IL/il.h>
    #include<stdlib.h> /* because of malloc() etc. */
    int main(int argc, const char * argv[])
    {
    ILuint handle, w, h;
    /* First we initialize the library. */
    /*Do not forget that... */
    ilInit();
    /* We want all images to be loaded in a consistent manner */
    ilEnable(IL_ORIGIN_SET);
    /* In the next section, we load one image */
    ilGenImages(1, & handle);
    ilBindImage(handle);
    ILboolean loaded = ilLoadImage("original_file.jpg");
    if (loaded == IL_FALSE)
    return -1; /* error encountered during loading */
    /* Let’s spy on it a little bit */
    w = ilGetInteger(IL_IMAGE_WIDTH); // getting image width
    h = ilGetInteger(IL_IMAGE_HEIGHT); // and height
    printf("Our image resolution: %dx%d\n", w, h);
    /* how much memory will we need? */
    int memory_needed = w * h * 3 * sizeof(unsigned char);
    /* We multiply by 3 here because we want 3 components per pixel */
    ILubyte * data = (ILubyte *)malloc(memory_needed);
    /* finally get the image data */
    ilCopyPixels(0, 0, 0, w, h, 1, IL_RGB, IL_UNSIGNED_BYTE, data);
    /* We want to do something with the image, right? */
    int i;
    for(i = 0; i < memory_needed; i++)
    if(i % 31 == 0) /* vandalise the image */
    data[i] = i % 255;
    /* And maybe we want to save that all... */
    ilSetPixels(0, 0, 0, w, h, 1, IL_RGB, IL_UNSIGNED_BYTE, data);
    /* and dump them to the disc... */
    ilSaveImage("our_result.png");
    /* Finally, clean the mess! */
    ilDeleteImages(1, & handle);
    free(data); data = NULL;
    return 0;
    }

    //
    // beginning of comments
    Hope this can be of some help
    unsigned int Manual = 0x00001;
    Lookup->Resources.at(Manual);
    ///
    By the way i use Code::Blocks..

     

Log in to post a comment.