Changeset 6838


Ignore:
Timestamp:
08/23/10 16:56:05 (9 years ago)
Author:
melissa
Message:

One more signedness fix, as pointed out by Rubén Muñoz.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java

    r6810 r6838  
    2525 
    2626import java.io.IOException; 
     27import java.nio.ByteOrder; 
    2728import java.util.Hashtable; 
    2829import java.util.Vector; 
    2930 
     31import loci.common.ByteArrayHandle; 
    3032import loci.common.DataTools; 
    3133import loci.common.Location; 
     
    189191      reader.openBytes(0, buf, x, y, w, h); 
    190192      reader.close(); 
     193 
     194      // mask out the sign bit 
     195      ByteArrayHandle pixels = new ByteArrayHandle(buf); 
     196      pixels.setOrder( 
     197        isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); 
     198      for (int i=0; i<buf.length; i+=2) { 
     199        pixels.seek(i); 
     200        short value = pixels.readShort(); 
     201        value = (short) (value & 0xfff); 
     202        pixels.seek(i); 
     203        pixels.writeShort(value); 
     204      } 
     205      buf = pixels.getBytes(); 
     206      pixels.close(); 
    191207    } 
    192208 
     
    415431      core[i].dimensionOrder = "XYCTZ"; 
    416432      core[i].imageCount = nSlices * nTimepoints * nChannels; 
     433      core[i].bitsPerPixel = 12; 
    417434    } 
    418435 
Note: See TracChangeset for help on using the changeset viewer.