Changeset 11825

Show
Ignore:
Timestamp:
08/01/07 19:04:17 (1 year ago)
Author:
warmerdam
Message:

avoiding rounding vagarities with color table computation (#1732)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/warmerdam/1.4-esri/gdal/frmts/hfa/hfadataset.cpp

    r11783 r11825  
    498498            GDALColorEntry   sEntry; 
    499499 
    500             sEntry.c1 = (short) (padfRed[iColor]   * 255); 
    501             sEntry.c2 = (short) (padfGreen[iColor] * 255); 
    502             sEntry.c3 = (short) (padfBlue[iColor]  * 255); 
    503             sEntry.c4 = (short) (padfAlpha[iColor]  * 255); 
     500            // The following mapping assigns "equal sized" section of  
     501            // the [0...1] range to each possible output value and avoid 
     502            // rounding issues for the "normal" values generated using n/255. 
     503            // See bug #1732 for some discussion. 
     504            sEntry.c1 = MIN(255,(short) (padfRed[iColor]   * 256)); 
     505            sEntry.c2 = MIN(255,(short) (padfGreen[iColor] * 256)); 
     506            sEntry.c3 = MIN(255,(short) (padfBlue[iColor]  * 256)); 
     507            sEntry.c4 = MIN(255,(short) (padfAlpha[iColor] * 256)); 
    504508            poCT->SetColorEntry( iColor, &sEntry ); 
    505509        }