Changeset 1817


Ignore:
Timestamp:
11/17/06 12:04:17 (14 years ago)
Author:
melissa
Message:

Set number of valid bits in OIB and OIF readers.

Location:
trunk/loci/formats/in
Files:
2 edited

Legend:

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

    r1781 r1817  
    8080  private int tSize; 
    8181 
    82   /* Number of Z slices. */ 
     82  /** Number of Z slices. */ 
    8383  private int zSize; 
    8484 
     
    109109  /** Vector containing T indices. */ 
    110110  private Vector tIndices; 
     111 
     112  /** Number of valid bits per pixel. */ 
     113  private int[] validBits; 
    111114 
    112115  private boolean littleEndian; 
     
    223226    int bytes = b.length / (width * height); 
    224227    return ImageTools.makeImage(b, width, height, bytes == 3 ? 3 : 1, 
    225       false, bytes == 3 ? 1 : bytes, !littleEndian); 
     228      false, bytes == 3 ? 1 : bytes, !littleEndian, validBits); 
    226229  } 
    227230 
     
    360363      sizeC[0] = nChannels; 
    361364      sizeT[0] = tSize; 
     365 
     366      validBits = new int[nChannels == 2 ? 3 : nChannels]; 
     367      int vb = 0; 
     368      Enumeration k = metadata.keys(); 
     369      while (k.hasMoreElements()) { 
     370        String key = k.nextElement().toString(); 
     371        if (key.indexOf("ValidBitCounts") != -1) { 
     372          vb = Integer.parseInt((String) metadata.get(key)); 
     373        } 
     374      } 
     375      if (vb > 0) {  
     376        for (int i=0; i<validBits.length; i++) validBits[i] = vb; 
     377      } 
     378      else validBits = null; 
     379 
    362380    } 
    363381    catch (Throwable t) { 
  • trunk/loci/formats/in/OIFReader.java

    r1812 r1817  
    5454  /** Helper reader to open the thumbnail. */ 
    5555  protected BMPReader thumbReader; 
     56 
     57  /** Number of valid bits per pixel. */ 
     58  private int[] validBits; 
    5659 
    5760  // -- Constructor -- 
     
    155158    tiffReader[no].setColorTableIgnored(ignoreColorTable); 
    156159    BufferedImage b = tiffReader[no].openImage((String) tiffs.get(no), 0); 
     160    b = ImageTools.makeBuffered(b, 
     161      ImageTools.makeColorModel(b.getRaster().getNumBands(), 
     162      b.getRaster().getTransferType(), validBits)); 
    157163    tiffReader[no].close(); 
    158164    return b; 
     
    349355    } 
    350356 
     357    validBits = new int[sizeC[0]]; 
     358    if (validBits.length == 2) validBits = new int[3]; 
     359    for (int i=0; i<validBits.length; i++) { 
     360      validBits[i] = Integer.parseInt((String) metadata.get("Image " + i +  
     361        " : ValidBitCounts")); 
     362    } 
     363 
    351364    store.setPixels( 
    352365      new Integer(Integer.parseInt((String) metadata.get("ImageWidth"))), 
Note: See TracChangeset for help on using the changeset viewer.