Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

alpha channel missing

Andrei I
2010-12-02
2013-05-02
  • Andrei I
    Andrei I
    2010-12-02

    Hi, I have just installed devIL on my linux machine and tried it in a simple project. The problem is that after the image was loaded and converted to RGBA format, the fourth byte is always 255 (the first three ones are ok). Here is my code:

    result = (imgSurface *)malloc(sizeof(imgSurface));
    ilGenImages(1, &result->loader);
    ilBindImage(result->loader);
    // load image
    if( !ilLoadImage(path) ){
        DBG("Error loading %s\n", path);
        ilDeleteImages(1, &result->loader);
        return NULL;
    }
    ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
    // get image bounds
    w = ilGetInteger(IL_IMAGE_WIDTH);
    h = ilGetInteger(IL_IMAGE_HEIGHT);
    d = ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
    result->width = w;
    result->height = h;
    result->depth = d;
    result->pixels = calloc(w*h,4);
    ilCopyPixels(0, 0, 0, w, h, 1, IL_RGBA, IL_UNSIGNED_BYTE, result->pixels);
    ilDeleteImages(1, &result->loader);
    
     
  • Andrei I
    Andrei I
    2010-12-02

    The image is certainly a 32 bit one because I have reduced transparency in gimp and saved as a 32 bit image.
    If I am loading the image with fopen .. fread I get the correct values for the alpha channel.

     
  • Andrei I
    Andrei I
    2010-12-03

    The problem is that libIL cannot handle the alpha channel for 32 bit bitmaps. So I need to load bmp's with fread and other types with libIL.

    Andrei