Changeset 4913


Ignore:
Timestamp:
03/13/09 14:04:23 (11 years ago)
Author:
melissa
Message:

Added loci.common.RandomAccessOutputStream (analogous to RandomAccessStream) and adapted writers to use it instead of IRandomAccess. LegacyQTWriter is now the only writer that does not use loci.common.

Location:
trunk/components
Files:
1 added
11 edited

Legend:

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

    r4900 r4913  
    17871787   */ 
    17881788  public static long writeImage(BufferedImage img, Hashtable ifd, 
    1789     IRandomAccess out, long offset, boolean last, boolean bigTiff) 
     1789    RandomAccessOutputStream out, long offset, boolean last, boolean bigTiff) 
    17901790    throws FormatException, IOException 
    17911791  { 
  • trunk/components/bio-formats/src/loci/formats/out/APNGWriter.java

    r4900 r4913  
    4848  // -- Fields -- 
    4949 
    50   private IRandomAccess out; 
     50  private RandomAccessOutputStream out; 
    5151  private int numFrames = 0; 
    5252  private long numFramesPointer = 0; 
     
    9090 
    9191    if (!initialized) { 
    92       out = Location.getHandle(currentId); 
     92      out = new RandomAccessOutputStream(currentId); 
    9393 
    9494      // write 8-byte PNG signature 
  • trunk/components/bio-formats/src/loci/formats/out/AVIWriter.java

    r4900 r4913  
    4646  // -- Fields -- 
    4747 
    48   private IRandomAccess out; 
     48  private RandomAccessOutputStream out; 
    4949 
    5050  private int planesWritten = 0; 
     
    130130      bytesPerPixel = byteData.length; 
    131131 
    132       out = Location.getHandle(currentId); 
     132      out = new RandomAccessOutputStream(currentId); 
    133133      out.seek(out.length()); 
    134134      saveFileSize = 4; 
  • trunk/components/bio-formats/src/loci/formats/out/EPSWriter.java

    r4900 r4913  
    4242 
    4343  /** Current file. */ 
    44   protected IRandomAccess out; 
     44  protected RandomAccessOutputStream out; 
    4545 
    4646  // -- Constructor -- 
     
    6060    } 
    6161 
    62     out = Location.getHandle(currentId); 
     62    out = new RandomAccessOutputStream(currentId); 
    6363 
    6464    BufferedImage img = AWTImageTools.makeBuffered(image, cm); 
  • trunk/components/bio-formats/src/loci/formats/out/ICSWriter.java

    r4900 r4913  
    4545  // -- Fields -- 
    4646 
    47   private IRandomAccess out; 
     47  private RandomAccessOutputStream out; 
    4848 
    4949  // -- Constructor -- 
     
    6767    if (!initialized) { 
    6868      initialized = true; 
    69       out = Location.getHandle(currentId); 
     69      out = new RandomAccessOutputStream(currentId); 
    7070      out.writeBytes("\t\n"); 
    7171      out.writeBytes("ics_version\t2.0\n"); 
  • trunk/components/bio-formats/src/loci/formats/out/ImageIOWriter.java

    r4550 r4913  
    4949 
    5050  protected String kind; 
    51   protected DataOutputStream out; 
     51  protected RandomAccessOutputStream out; 
    5252 
    5353  // -- Constructors -- 
     
    8080      throw new FormatException("Floating point data not supported."); 
    8181    } 
    82     out = new DataOutputStream(new BufferedOutputStream( 
    83       new FileOutputStream(currentId), 4096)); 
     82    out = new RandomAccessOutputStream(currentId); 
    8483    ImageIO.write(img, kind, out); 
    8584  } 
  • trunk/components/bio-formats/src/loci/formats/out/JPEG2000Writer.java

    r4900 r4913  
    4444  // -- Fields -- 
    4545 
    46   private IRandomAccess out; 
     46  private RandomAccessOutputStream out; 
    4747 
    4848  // -- Constructor -- 
     
    8383    int bytesPerPixel = byteData[0].length / (img.getWidth() * img.getHeight()); 
    8484 
    85     out = Location.getHandle(currentId); 
     85    out = new RandomAccessOutputStream(currentId); 
    8686 
    8787    CodecOptions options = new CodecOptions(); 
  • trunk/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r4900 r4913  
    4747 
    4848  private Vector xmlFragments; 
    49   private IRandomAccess out; 
     49  private RandomAccessOutputStream out; 
    5050  private String currentFragment; 
    5151 
     
    7676    MetadataRetrieve retrieve = getMetadataRetrieve(); 
    7777    if (!initialized) { 
    78       out = Location.getHandle(currentId); 
     78      out = new RandomAccessOutputStream(currentId); 
    7979 
    8080      String xml = MetadataTools.getOMEXML(retrieve); 
  • trunk/components/bio-formats/src/loci/formats/out/QTWriter.java

    r4900 r4913  
    8585 
    8686  /** Current file. */ 
    87   protected IRandomAccess out; 
     87  protected RandomAccessOutputStream out; 
    8888 
    8989  /** The codec to use. */ 
     
    233233 
    234234      offsets = new Vector(); 
    235       out = Location.getHandle(currentId); 
     235      out = new RandomAccessOutputStream(currentId); 
    236236      created = (int) System.currentTimeMillis(); 
    237237      numWritten = 0; 
     
    250250      else { 
    251251        out.seek(byteCountOffset); 
    252         numBytes = (int) DataTools.read4UnsignedBytes(out, false) - 8; 
     252 
     253        RandomAccessStream in = new RandomAccessStream(currentId); 
     254        in.seek(byteCountOffset); 
     255        numBytes = (int) DataTools.read4UnsignedBytes(in, false) - 8; 
     256        in.close(); 
     257 
    253258        numWritten = numBytes / buffer.length; 
    254259        numBytes += buffer.length; 
  • trunk/components/bio-formats/src/loci/formats/out/TiffWriter.java

    r4900 r4913  
    4747 
    4848  /** Current output stream. */ 
    49   protected IRandomAccess out; 
     49  protected RandomAccessOutputStream out; 
    5050 
    5151  /** Image counts for each open series. */ 
     
    100100      imageCounts = new Vector(); 
    101101      initialized = true; 
    102       out = Location.getHandle(currentId); 
     102      out = new RandomAccessOutputStream(currentId); 
    103103 
    104104      RandomAccessStream tmp = new RandomAccessStream(currentId); 
  • trunk/components/common/src/loci/common/Location.java

    r4900 r4913  
    138138 
    139139  /** 
     140   * Gets an IRandomAccess object that can read from the given file. 
     141   * @see IRandomAccess 
     142   */ 
     143  public static IRandomAccess getHandle(String id) throws IOException { 
     144    return getHandle(id, false); 
     145  } 
     146 
     147  /** 
    140148   * Gets an IRandomAccess object that can read from or write to the given file. 
    141149   * @see IRandomAccess 
    142150   */ 
    143   public static IRandomAccess getHandle(String id) throws IOException { 
     151  public static IRandomAccess getHandle(String id, boolean writable) 
     152    throws IOException 
     153  { 
    144154    File f = new File(getMappedId(id)).getAbsoluteFile(); 
    145155    if (getMappedFile(id) != null) return getMappedFile(id); 
     
    147157    IRandomAccess handle = null; 
    148158    if (id.startsWith("http://")) { 
    149       handle = new RAUrl(getMappedId(id), "r"); 
     159      handle = new RAUrl(getMappedId(id), writable ? "rw" : "r"); 
    150160    } 
    151161    else { 
    152       handle = new RAFile(f, "r"); 
     162      handle = new RAFile(f, writable ? "rw" : "r"); 
    153163    } 
    154164    return handle; 
Note: See TracChangeset for help on using the changeset viewer.