Ignore:
Timestamp:
Apr 4, 2009, 4:49:00 PM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r1196 r1380  
    2929
    3030    char header[54];
    31     fread(&header, 54, 1, f);
     31    if (fread(&header, 54, 1, f) != 1) {
     32        printf("can't read header of BMP file\n");
     33        return 0;
     34    };
    3235
    3336    if (header[0] != 'B' ||  header[1] != 'M') {
     
    6669        fseek(f,offset,SEEK_SET);
    6770        if (_targetImageFormat == Image::IMG_RGB) {
    68             fread(bytes,width*height*3,1,f); //24bit is easy
     71            if (fread(bytes,width*height*3,1,f) != 1) {
     72                fprintf(stderr, "can't read image data\n");
     73            }
    6974            for(x=0;x<width*height*3;x+=3)  { //except the format is BGR, grr
    7075                unsigned char temp = bytes[x];
     
    7479        } else if (_targetImageFormat == Image::IMG_RGBA) {
    7580            char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3);
    76             fread(buff,width*height*3,1,f);                 //24bit is easy
     81            if (fread(buff,width*height*3,1,f) != 1) {
     82                fprintf(stderr, "can't read BMP image data\n");
     83            }
    7784            for(x=0, y = 0;x<width*height*3;x+=3, y+=4)     {       //except the format is BGR, grr
    7885                bytes[y] = buff[x+2];
     
    8491        break;
    8592    case 8:
    86         fread(cols,256 * 4,1,f); //read colortable
     93        if (fread(cols,256 * 4,1,f) != 1) {
     94            fprintf(stderr, "can't read colortable from BMP file\n");
     95        }
    8796        fseek(f,offset,SEEK_SET); 
    8897        for(y=0;y<height;++y) { //(Notice 4bytes/col for some reason)
    8998            for(x=0;x<width;++x) {
    9099                unsigned char byte;                 
    91                 fread(&byte,1,1,f);                                                 //just read byte                                       
     100                if (fread(&byte,1,1,f) != 1) {
     101                    fprintf(stderr, "error reading BMP file\n");
     102                }
    92103                for(int c=0; c< 3; ++c) {
    93104                    //bytes[(y*width+x)*3+c] = cols[byte*4+2-c];        //and look up in the table
Note: See TracChangeset for help on using the changeset viewer.