Changeset 7004


Ignore:
Timestamp:
09/28/10 11:30:35 (9 years ago)
Author:
melissa
Message:

Merged TIFF export fixes into 4.2: r6878, r6976, and r6977.

Location:
branches/4.2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

  • branches/4.2/components/bio-formats/src/loci/formats/in

  • branches/4.2/components/bio-formats/src/loci/formats/meta

  • branches/4.2/components/bio-formats/src/loci/formats/ome

  • branches/4.2/components/bio-formats/src/loci/formats/out/OMETiffWriter.java

    r7003 r7004  
    8181  private OMEXMLMetadata omeMeta; 
    8282  private OMEXMLService service; 
     83  private HashMap<String, Integer> ifdCounts = new HashMap<String, Integer>(); 
    8384 
    8485  // -- Constructor -- 
     
    139140        omeMeta = null; 
    140141        service = null; 
     142        ifdCounts.clear(); 
    141143      } 
    142144    } 
     
    290292    sizeC /= samplesPerPixel.getValue(); 
    291293 
    292     HashMap<String, Integer> ifdCounts = new HashMap<String, Integer>(); 
    293  
    294294    for (int plane=0; plane<imageCount; plane++) { 
    295295      int[] zct = FormatTools.getZCTCoords(dimensionOrder, 
  • branches/4.2/components/bio-formats/src/loci/formats/out/TiffWriter.java

    r6947 r7004  
    6161  protected boolean isBigTiff; 
    6262 
     63  /** Whether or not we are writing planes sequentially. */ 
     64  protected boolean sequential; 
     65 
    6366  /** The TiffSaver that will do most of the writing. */ 
    6467  protected TiffSaver tiffSaver; 
     
    116119 
    117120    tiffSaver = new TiffSaver(out); 
     121    tiffSaver.setWritingSequentially(sequential); 
    118122    tiffSaver.setLittleEndian(littleEndian); 
    119123    tiffSaver.setBigTiff(isBigTiff); 
     
    180184    ifd.putIFDValue(IFD.PLANAR_CONFIGURATION, interleaved ? 1 : 2); 
    181185    RandomAccessInputStream in = new RandomAccessInputStream(currentId); 
     186    in.order(littleEndian); 
    182187    tiffSaver.setInputStream(in); 
    183     tiffSaver.writeImage(buf, ifd, no, type, x, y, w, h, 
    184       no == getPlaneCount() - 1); 
     188 
     189    int index = no; 
     190    int realSeries = getSeries(); 
     191    for (int i=0; i<realSeries; i++) { 
     192      setSeries(i); 
     193      index += getPlaneCount(); 
     194    } 
     195    setSeries(realSeries); 
     196 
     197    tiffSaver.writeImage(buf, ifd, index, type, x, y, w, h, 
     198      no == getPlaneCount() - 1 && getSeries() == retrieve.getImageCount() - 1); 
    185199    tiffSaver.setInputStream(null); 
    186200    in.close(); 
     
    236250  } 
    237251 
     252  /** 
     253   * Sets whether or not we know that planes will be written sequentially. 
     254   * If planes are written sequentially and this flag is set, then performance 
     255   * will be slightly improved. 
     256   */ 
     257  public void setWriteSequentially(boolean sequential) { 
     258    this.sequential = sequential; 
     259  } 
     260 
    238261} 
  • branches/4.2/components/bio-formats/src/loci/formats/tiff

  • branches/4.2/components/bio-formats/src/loci/formats/tiff/TiffParser.java

    r7003 r7004  
    8888    this.in = in; 
    8989    doCaching = true; 
     90    try { 
     91      long fp = in.getFilePointer(); 
     92      checkHeader(); 
     93      in.seek(fp); 
     94    } 
     95    catch (IOException e) { } 
    9096  } 
    9197 
     
    568574    in.read(tile); 
    569575 
    570     options.maxBytes = size; 
     576    options.maxBytes = (int) Math.max(size, tile.length); 
    571577 
    572578    if (jpegTable != null) { 
  • branches/4.2/components/bio-formats/src/loci/formats/tiff/TiffSaver.java

    r6508 r7004  
    6868  /** Whether or not to write BigTIFF data. */ 
    6969  private boolean bigTiff = false; 
     70  private boolean sequentialWrite = false; 
    7071 
    7172  // -- Constructors -- 
     
    8586 
    8687  // -- TiffSaver methods -- 
     88 
     89  /** 
     90   * Sets whether or not we know that the planes will be written sequentially. 
     91   * If we are writing planes sequentially and set this flag, then performance 
     92   * is slightly improved. 
     93   */ 
     94  public void setWritingSequentially(boolean sequential) { 
     95    sequentialWrite = sequential; 
     96  } 
    8797 
    8898  /** Sets the input stream. */ 
     
    246256      TiffCompression.difference(strips[strip], ifd); 
    247257      CodecOptions options = compression.getCompressionCodecOptions(ifd); 
     258      options.height = rowsPerStrip; 
    248259      strips[strip] = compression.compress(strips[strip], options); 
    249260    } 
    250261 
    251     TiffParser parser = new TiffParser(in); 
    252     long[] ifdOffsets = parser.getIFDOffsets(); 
    253     if (no < ifdOffsets.length) { 
    254       out.seek(ifdOffsets[no]); 
    255       ifd = parser.getIFD(ifdOffsets[no]); 
     262    if (!sequentialWrite) { 
     263      TiffParser parser = new TiffParser(in); 
     264      long[] ifdOffsets = parser.getIFDOffsets(); 
     265      if (no < ifdOffsets.length) { 
     266        out.seek(ifdOffsets[no]); 
     267        ifd = parser.getIFD(ifdOffsets[no]); 
     268      } 
    256269    } 
    257270 
     
    322335      writeIFDValue(extraStream, ifdBytes + fp, key.intValue(), value); 
    323336    } 
     337    if (bigTiff) out.seek(out.getFilePointer() - 8); 
    324338    writeIntValue(out, nextOffset); 
    325339    out.write(extra.getBytes(), 0, (int) extra.length()); 
  • branches/4.2/components/bio-formats/src/loci/formats/tools/ImageConverter.java

    r7003 r7004  
    211211    if (writer instanceof TiffWriter) { 
    212212      ((TiffWriter) writer).setBigTiff(bigtiff); 
     213      ((TiffWriter) writer).setWriteSequentially(true); 
    213214    } 
    214215    else if (writer instanceof ImageWriter) { 
     
    216217      if (w instanceof TiffWriter) { 
    217218        ((TiffWriter) w).setBigTiff(bigtiff); 
     219        ((TiffWriter) w).setWriteSequentially(true); 
    218220      } 
    219221    } 
  • branches/4.2/components/bio-formats/test/loci/formats/utests

  • branches/4.2/components/ome-xml

Note: See TracChangeset for help on using the changeset viewer.