Ignore:
Timestamp:
Apr 19, 2010, 8:43:19 PM (14 years ago)
Author:
vrinside
Message:

supported RGBA BMP files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp

    r1380 r1705  
    9090        }
    9191        break;
     92    case 32:
     93        fseek(f,offset,SEEK_SET);
     94        if (_targetImageFormat == Image::IMG_RGBA) {
     95            if (fread(bytes,width*height*4,1,f) != 1) {
     96                fprintf(stderr, "can't read image data\n");
     97            }
     98            for(x=0;x<width*height*4;x+=4)  { //except the format is BGR, grr
     99                unsigned char temp = bytes[x];
     100                bytes[x] = bytes[x+2];
     101                bytes[x+2] = temp;
     102            }
     103        }
     104        else if (_targetImageFormat == Image::IMG_RGB) {
     105            char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3);
     106            if (fread(buff,width*height*4,1,f) != 1) {
     107                fprintf(stderr, "can't read BMP image data\n");
     108            }
     109            for(x=0, y = 0;x<width*height*4;x+=4, y+=3)     {       //except the format is BGR, grr
     110                bytes[y] = buff[x+2];
     111                bytes[y+2] = buff[x];
     112            }
     113            free(buff);
     114        }
     115        break;
    92116    case 8:
    93117        if (fread(cols,256 * 4,1,f) != 1) {
Note: See TracChangeset for help on using the changeset viewer.