Changeset 7145


Ignore:
Timestamp:
10/30/10 12:31:57 (9 years ago)
Author:
melissa
Message:
  • Fixed multi-series OME-XML export.
  • Fixed multi-series OME-TIFF export.
  • Fixed assorted problems with exporting TIFF files when the original data contained 2 or > 3 merged channels.
Location:
branches/4.2/components/bio-formats/src/loci/formats/out
Files:
3 edited

Legend:

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

    r7007 r7145  
    101101 
    102102        for (int series=0; series<omeMeta.getImageCount(); series++) { 
     103          setSeries(series); 
    103104          populateImage(omeMeta, series); 
    104105        } 
     
    164165    for (int s=0; s<currentSeries; s++) { 
    165166      setSeries(s); 
    166       index -= getPlaneCount(); 
     167      index -= planeCount(); 
    167168    } 
    168169    setSeries(currentSeries); 
     
    171172    totalPlanes++; 
    172173 
    173     wroteLast = series == r.getImageCount() - 1 && index == getPlaneCount() - 1; 
     174    wroteLast = series == r.getImageCount() - 1 && index == planeCount() - 1; 
    174175  } 
    175176 
     
    185186      for (int i=0; i<imageLocations.length; i++) { 
    186187        setSeries(i); 
    187         imageLocations[i] = new String[getPlaneCount()]; 
     188        imageLocations[i] = new String[planeCount()]; 
    188189      } 
    189190      setSeries(0); 
     
    295296      int[] zct = FormatTools.getZCTCoords(dimensionOrder, 
    296297        sizeZ, sizeC, sizeT, imageCount, plane); 
    297       String filename = new Location(imageLocations[series][plane]).getName(); 
     298 
     299      int planeIndex = plane; 
     300      if (imageLocations[series].length < imageCount) { 
     301        planeIndex /= (imageCount / imageLocations[series].length); 
     302      } 
     303 
     304      String filename = 
     305        new Location(imageLocations[series][planeIndex]).getName(); 
    298306 
    299307      Integer ifdIndex = ifdCounts.get(filename); 
     
    310318  } 
    311319 
     320  private int planeCount() { 
     321    MetadataRetrieve r = getMetadataRetrieve(); 
     322    int z = r.getPixelsSizeZ(series).getValue().intValue(); 
     323    int t = r.getPixelsSizeT(series).getValue().intValue(); 
     324    int c = r.getChannelCount(series); 
     325    return z * c * t; 
     326  } 
     327 
    312328} 
  • branches/4.2/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r7007 r7145  
    9898 
    9999    xmlFragments.add(currentFragment); 
    100     if (out.length() == 0) { 
    101       out.writeBytes(xmlFragments.get(0)); 
    102     } 
    103100  } 
    104101 
     
    106103  public void close() throws IOException { 
    107104    if (out != null) { 
    108       out.writeBytes(xmlFragments.get(series + 1)); 
     105      out.writeBytes(xmlFragments.get(xmlFragments.size() - 1)); 
    109106    } 
    110107    super.close(); 
     
    126123    } 
    127124    MetadataRetrieve retrieve = getMetadataRetrieve(); 
     125 
     126    if (no == 0) { 
     127      out.writeBytes(xmlFragments.get(series)); 
     128    } 
    128129 
    129130    String type = retrieve.getPixelsType(series).toString(); 
  • branches/4.2/components/bio-formats/src/loci/formats/out/TiffWriter.java

    r7007 r7145  
    6767  protected TiffSaver tiffSaver; 
    6868 
     69  /** Whether or not to check the parameters passed to saveBytes. */ 
     70  private boolean checkParams = true; 
     71 
    6972  // -- Constructors -- 
    7073 
     
    112115    throws IOException, FormatException 
    113116  { 
    114     checkParams(no, buf, x, y, w, h); 
     117    if (checkParams) checkParams(no, buf, x, y, w, h); 
    115118    MetadataRetrieve retrieve = getMetadataRetrieve(); 
    116119    Boolean bigEndian = retrieve.getPixelsBinDataBigEndian(series, 0); 
     
    149152    if (bytesPerPixel > 1 && c != 1 && c != 3) { 
    150153      // split channels 
     154      checkParams = false; 
     155 
     156      if (no == 0) { 
     157        initialized[series] = new boolean[initialized[series].length * c]; 
     158      } 
     159 
    151160      for (int i=0; i<c; i++) { 
    152161        byte[] b = ImageTools.splitChannels(buf, i, c, bytesPerPixel, 
    153162          false, interleaved); 
    154163 
    155         saveBytes(no, b, ifd, x, y, w, h); 
    156       } 
     164        saveBytes(no + i, b, ifd, x, y, w, h); 
     165      } 
     166      checkParams = true; 
    157167      return; 
    158168    } 
     
    199209    tiffSaver.setInputStream(null); 
    200210    in.close(); 
     211  } 
     212 
     213  // -- FormatWriter API methods -- 
     214 
     215  protected int getPlaneCount() { 
     216    int c = getSamplesPerPixel(); 
     217    if (c == 1 || c == 3) return super.getPlaneCount(); 
     218    return c * super.getPlaneCount(); 
    201219  } 
    202220 
Note: See TracChangeset for help on using the changeset viewer.