Changeset 3151


Ignore:
Timestamp:
09/11/07 09:10:56 (13 years ago)
Author:
melissa
Message:

Bugfixes; final what's new update for next release.

Location:
trunk/loci/formats
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/doc/whats-new.txt

    r3142 r3151  
    1 2007 Sept 7: 
     12007 Sept 11: 
    22* Major improvements to ND2 support - lossless compression now supported 
    33* Support for indexed color images 
     4* Added support for Simple-PCI .cxd files 
    45* Command-line OME-XML validation 
    5 * Bugfixes in most readers, especially Zeiss ZVI, PerkinElmer and Leica LEI 
     6* Bugfixes in most readers, especially Zeiss ZVI, Metamorph, PerkinElmer and Leica LEI 
    67* Initial version of Bio-Formats macro extensions for ImageJ 
    78 
     
    1213* Added OME-TIFF writer 
    1314* Added MetadataRetrieve API for retrieving data from a MetadataStore 
    14 * Miscellaneous bugfixes  
     15* Miscellaneous bugfixes 
    1516 
    16172007 July 16: 
  • trunk/loci/formats/in/IPWReader.java

    r3060 r3151  
    2525package loci.formats.in; 
    2626 
    27 import java.awt.image.BufferedImage; 
     27import java.awt.image.*; 
    2828import java.io.*; 
    2929import java.util.*; 
     
    108108      throw new FormatException("Invalid image number: " + no); 
    109109    } 
    110  
    111     try { 
    112       String directory = (String) pixels.get(new Integer(no)); 
    113       String name = (String) names.get(new Integer(no)); 
    114  
    115       r.setVar("dirName", directory); 
    116       r.exec("root = fs.getRoot()"); 
    117  
    118       if (!directory.equals("Root Entry")) { 
    119         r.exec("dir = root.getEntry(dirName)"); 
    120         r.setVar("entryName", name); 
    121         r.exec("document = dir.getEntry(entryName)"); 
    122       } 
    123       else { 
    124         r.setVar("entryName", name); 
    125         r.exec("document = root.getEntry(entryName)"); 
    126       } 
    127  
    128       r.exec("dis = new DocumentInputStream(document)"); 
    129       r.exec("numBytes = dis.available()"); 
    130       int numBytes = ((Integer) r.getVar("numBytes")).intValue(); 
    131       byte[] b = new byte[numBytes + 4]; 
    132       r.setVar("data", b); 
    133       r.exec("dis.read(data)"); 
    134  
    135       RandomAccessStream stream = new RandomAccessStream(b); 
    136       ifds = TiffTools.getIFDs(stream); 
    137       core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
    138       TiffTools.getSamples(ifds[0], stream, buf); 
    139       stream.close(); 
    140       return buf; 
    141     } 
    142     catch (ReflectException e) { 
    143       noPOI = true; 
    144       return null; 
    145     } 
     110    if (buf.length < core.sizeX[0] * core.sizeY[0] * 
     111      FormatTools.getBytesPerPixel(core.pixelType[0]) * 
     112      ((isRGB() && !isIndexed()) ? core.sizeC[0] : 1)) 
     113    { 
     114      throw new FormatException("Buffer too small."); 
     115    } 
     116 
     117    RandomAccessStream stream = getStream(no); 
     118    ifds = TiffTools.getIFDs(stream); 
     119    core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
     120    TiffTools.getSamples(ifds[0], stream, buf); 
     121    stream.close(); 
     122    return buf; 
    146123  } 
    147124 
    148125  /* @see loci.formats.IFormatReader#openImage(int) */ 
    149126  public BufferedImage openImage(int no) throws FormatException, IOException { 
    150     byte[] b = openBytes(no); 
    151     int bytes = b.length / (core.sizeX[0] * core.sizeY[0]); 
    152     return ImageTools.makeImage(b, core.sizeX[0], core.sizeY[0], 
    153       bytes == 3 ? 3 : 1, false, bytes == 3 ? 1 : bytes, core.littleEndian[0]); 
     127    FormatTools.assertId(currentId, true, 1); 
     128    if (no < 0 || no >= getImageCount()) { 
     129      throw new FormatException("Invalid image number: " + no); 
     130    } 
     131 
     132    RandomAccessStream stream = getStream(no); 
     133    ifds = TiffTools.getIFDs(stream); 
     134    BufferedImage b = TiffTools.getImage(ifds[0], stream); 
     135    if (isIndexed()) { 
     136      IndexedColorModel model = null; 
     137      if (core.pixelType[0] == FormatTools.UINT8) { 
     138        byte[][] table = get8BitLookupTable(); 
     139        model = new IndexedColorModel(8, table[0].length, table); 
     140      } 
     141      else if (core.pixelType[0] == FormatTools.UINT16) { 
     142        short[][] table = get16BitLookupTable(); 
     143        model = new IndexedColorModel(16, table[0].length, table); 
     144      } 
     145      if (model != null) { 
     146        WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
     147          b.getData().getDataBuffer(), null); 
     148        b = new BufferedImage(model, raster, false, null); 
     149      } 
     150    } 
     151    return b; 
    154152  } 
    155153 
     
    460458  } 
    461459 
     460  /** Retrieve the file corresponding to the given image number. */ 
     461  private RandomAccessStream getStream(int no) throws IOException { 
     462    try { 
     463      String directory = (String) pixels.get(new Integer(no)); 
     464      String name = (String) names.get(new Integer(no)); 
     465 
     466      r.setVar("dirName", directory); 
     467      r.exec("root = fs.getRoot()"); 
     468 
     469      if (!directory.equals("Root Entry")) { 
     470        r.exec("dir = root.getEntry(dirName)"); 
     471        r.setVar("entryName", name); 
     472        r.exec("document = dir.getEntry(entryName)"); 
     473      } 
     474      else { 
     475        r.setVar("entryName", name); 
     476        r.exec("document = root.getEntry(entryName)"); 
     477      } 
     478 
     479      r.exec("dis = new DocumentInputStream(document)"); 
     480      r.exec("numBytes = dis.available()"); 
     481      int numBytes = ((Integer) r.getVar("numBytes")).intValue(); 
     482      byte[] b = new byte[numBytes + 4]; 
     483      r.setVar("data", b); 
     484      r.exec("dis.read(data)"); 
     485 
     486      return new RandomAccessStream(b);  
     487    } 
     488    catch (ReflectException e) { 
     489      noPOI = true; 
     490      return null; 
     491    } 
     492  } 
     493 
    462494  /** Debugging helper method. */ 
    463495  protected void print(int depth, String s) { 
  • trunk/loci/formats/in/KhorosReader.java

    r3139 r3151  
    9898    int bufSize = core.sizeX[0] * core.sizeY[0] * 
    9999      FormatTools.getBytesPerPixel(core.pixelType[0]); 
    100     if (isIndexed()) bufSize *= core.sizeC[0]; 
     100    if (!isIndexed()) bufSize *= core.sizeC[0]; 
    101101    if (buf.length < bufSize) throw new FormatException("Buffer too small."); 
    102102 
Note: See TracChangeset for help on using the changeset viewer.