Changeset 3948


Ignore:
Timestamp:
04/17/08 12:39:29 (12 years ago)
Author:
melissa
Message:

When applying scaling factors, don't assume that the source image is 8-bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/FlexReader.java

    r3854 r3948  
    7676    FormatTools.assertId(currentId, true, 1); 
    7777 
     78    int nBytes = TiffTools.getBitsPerSample(ifds[no])[0] / 8; 
     79 
    7880    // expand pixel values with multiplication by factor[no] 
    7981    byte[] bytes = super.openBytes(no, buf, x, y, w, h); 
     
    8890      int num = bytes.length / 2; 
    8991      for (int i=num-1; i>=0; i--) { 
    90         int q = (int) ((bytes[i] & 0xff) * factors[no]); 
     92        int q = nBytes == 1 ? (int) ((bytes[i] & 0xff) * factors[no]) : 
     93          (int) (DataTools.bytesToInt(bytes, i*2, 2, core.littleEndian[0]) * 
     94          factors[no]); 
    9195        DataTools.unpackBytes(q, bytes, i * 2, 2, core.littleEndian[0]); 
    9296      } 
     
    9599      int num = bytes.length / 4; 
    96100      for (int i=num-1; i>=0; i--) { 
    97         int q = (int) ((bytes[i] & 0xff) * factors[no]); 
     101        int q = nBytes == 1 ? (int) ((bytes[i] & 0xff) * factors[no]) : 
     102          (int) (DataTools.bytesToInt(bytes, i*4, nBytes, 
     103          core.littleEndian[0]) * factors[no]); 
    98104        DataTools.unpackBytes(q, bytes, i * 4, 4, core.littleEndian[0]); 
    99105      } 
     
    177183    if (factors[max] > 256) core.pixelType[0] = FormatTools.UINT32; 
    178184    else if (factors[max] > 1) core.pixelType[0] = FormatTools.UINT16; 
    179     else core.pixelType[0] = FormatTools.UINT8; 
    180185  } 
    181186 
Note: See TracChangeset for help on using the changeset viewer.