Changeset 6747


Ignore:
Timestamp:
07/28/10 16:38:36 (9 years ago)
Author:
melissa
Message:
  • Added 'int getSeries()' method to IFormatWriter.
  • Implemented non-deprecated saveImage methods in BufferedImageWriter. Closes #519.
Location:
trunk/components/bio-formats/src/loci/formats
Files:
5 edited

Legend:

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

    r6727 r6747  
    144144  } 
    145145 
     146  /* @see IFormatWriter#getSeries() */ 
     147  public int getSeries() { 
     148    return series; 
     149  } 
     150 
    146151  /* @see IFormatWriter#setInterleaved(boolean) */ 
    147152  public void setInterleaved(boolean interleaved) { 
  • trunk/components/bio-formats/src/loci/formats/IFormatWriter.java

    r6328 r6747  
    9696  void setSeries(int series) throws FormatException; 
    9797 
     98  /** Returns the current series. */ 
     99  int getSeries(); 
     100 
    98101  /** Sets whether or not the channels in an image are interleaved. */ 
    99102  void setInterleaved(boolean interleaved); 
  • trunk/components/bio-formats/src/loci/formats/ImageWriter.java

    r6294 r6747  
    217217  } 
    218218 
     219  /* @see IFormatWriter#getSeries() */ 
     220  public int getSeries() { 
     221    return getWriter().getSeries(); 
     222  } 
     223 
    219224  /* @see IFormatWriter#setInterleaved(boolean) */ 
    220225  public void setInterleaved(boolean interleaved) { 
  • trunk/components/bio-formats/src/loci/formats/WriterWrapper.java

    r6294 r6747  
    171171  } 
    172172 
     173  public int getSeries() { 
     174    return writer.getSeries(); 
     175  } 
     176 
    173177  public void setInterleaved(boolean interleaved) { 
    174178    writer.setInterleaved(interleaved); 
  • trunk/components/bio-formats/src/loci/formats/gui/BufferedImageWriter.java

    r6294 r6747  
    4242public class BufferedImageWriter extends WriterWrapper { 
    4343 
     44  // -- Fields -- 
     45 
     46  /** 
     47   * Number of planes written.  Only required by deprecated saveImage method. 
     48   */ 
     49  private int numWritten = 0; 
     50 
    4451  // -- Utility methods -- 
    4552 
     
    6370 
    6471  /** 
    65    * @deprecated 
    6672   * Saves the given BufferedImage to the current file. 
    67    * Note that this method will append the image plane to the file; it will not 
    68    * overwrite previously saved image planes. 
    69    * If this image plane is the last one in the file, the last flag must be set. 
     73   * 
     74   * @param no the image index within the current file, starting from 0. 
     75   * @param image the BufferedImage to save. 
    7076   */ 
    71   public void saveImage(BufferedImage image, boolean last) 
     77  public void saveImage(int no, BufferedImage image) 
    7278    throws FormatException, IOException 
    7379  { 
    74     saveImage(image, 0, last, last); 
     80    saveImage(no, image, 0, 0, image.getWidth(), image.getHeight()); 
    7581  } 
    7682 
    7783  /** 
    78    * @deprecated 
    79    * Saves the given BufferedImage to the given series in the current file. 
    80    * Note that this method will append the image plane to the file; it will not 
    81    * overwrite previously saved image planes. 
    82    * If this image plane is the last one in the series, the lastInSeries flag 
    83    * must be set. 
    84    * If this image plane is the last one in the file, the last flag must be set. 
     84   * Saves the given BufferedImage to the current file.  The BufferedImage 
     85   * may represent a subsection of the full image to be saved. 
     86   * 
     87   * @param no the image index within the current file, starting from 0. 
     88   * @param image the BufferedImage to save. 
     89   * @param x the X coordinate of the upper-left corner of the image. 
     90   * @param y the Y coordinate of the upper-left corner of the image. 
     91   * @param w the width (in pixels) of the image. 
     92   * @param h the height (in pixels) of the image. 
    8593   */ 
    86   public void saveImage(BufferedImage image, int series, 
    87     boolean lastInSeries, boolean last) throws FormatException, IOException 
     94  public void saveImage(int no, BufferedImage image, int x, int y, int w, int h) 
     95    throws FormatException, IOException 
    8896  { 
    8997    Class dataType = getNativeDataType(); 
    9098    if (BufferedImage.class.isAssignableFrom(dataType)) { 
    9199      // native data type is compatible with BufferedImage 
    92       savePlane(image, series, lastInSeries, last); 
     100      savePlane(no, image, x, y, w, h); 
    93101    } 
    94102    else { 
     
    100108      MetadataRetrieve r = getMetadataRetrieve(); 
    101109      if (r != null) { 
    102         Boolean bigEndian = r.getPixelsBinDataBigEndian(series, 0); 
     110        Boolean bigEndian = r.getPixelsBinDataBigEndian(getSeries(), 0); 
    103111        if (bigEndian != null) littleEndian = !bigEndian.booleanValue(); 
    104112      } 
     
    122130      pixelBytes = null; 
    123131 
    124       saveBytes(buf, series, lastInSeries, last); 
     132      saveBytes(no, buf, x, y, w, h); 
    125133    } 
    126134  } 
    127135 
     136  // -- IFormatHandler API methods -- 
     137 
     138  /* @see loci.formats.IFormatHandler#close() */ 
     139  public void close() throws IOException { 
     140    super.close(); 
     141    numWritten = 0; 
     142  } 
     143 
     144  // -- deprecated BufferedImageWriter methods -- 
     145 
     146  /** 
     147   * @deprecated Please use saveImage(int, BufferedImage) instead. 
     148   * Saves the given BufferedImage to the current file. 
     149   * Note that this method will append the image plane to the file; it will not 
     150   * overwrite previously saved image planes. 
     151   * If this image plane is the last one in the file, the last flag must be set. 
     152   */ 
     153  public void saveImage(BufferedImage image, boolean last) 
     154    throws FormatException, IOException 
     155  { 
     156    saveImage(image, 0, last, last); 
     157  } 
     158 
     159  /** 
     160   * @deprecated Please use saveImage(int, BufferedImage) instead. 
     161   * Saves the given BufferedImage to the given series in the current file. 
     162   * Note that this method will append the image plane to the file; it will not 
     163   * overwrite previously saved image planes. 
     164   * If this image plane is the last one in the series, the lastInSeries flag 
     165   * must be set. 
     166   * If this image plane is the last one in the file, the last flag must be set. 
     167   */ 
     168  public void saveImage(BufferedImage image, int series, 
     169    boolean lastInSeries, boolean last) throws FormatException, IOException 
     170  { 
     171    setSeries(series); 
     172    saveImage(numWritten++, image); 
     173  } 
     174 
    128175} 
Note: See TracChangeset for help on using the changeset viewer.