Changeset 5877 for branches/cleanup


Ignore:
Timestamp:
02/02/10 07:51:17 (10 years ago)
Author:
callan
Message:

#463 Cleanup of locations of inefficient legacy DataTools usage

  • With r5876 usage of the ByteBuffer is now possible, added accessor
Location:
branches/cleanup/components
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/src/loci/formats/gui/AWTTiffTools.java

    r5863 r5877  
    264264 
    265265    // flush buffers to output stream 
    266     // FIXME: BEGIN block to review for Stream --> Stream "buffered" transfer 
    267     // once Melissa adjusts RAInputStream and RAOutputStream.  
    268266    ifdBuf.seek(0); 
    269     byte[] ifdArray = new byte[(int) ifdBuf.length()]; 
    270     ifdBuf.read(ifdArray); 
    271267    extraBuf.seek(0); 
    272     byte[] extraArray = new byte[(int) extraBuf.length()]; 
    273     extraBuf.read(extraArray); 
    274     // END block to review 
    275     long numBytes = ifdArray.length + extraArray.length; 
    276     out.write(ifdArray); 
     268    long numBytes = ifdBuf.length() + extraBuf.length(); 
     269    out.write(ifdBuf.getByteBuffer()); 
    277270    for (int i=0; i<strips.length; i++) { 
    278271      out.write(strips[i]); 
    279272      numBytes += strips[i].length; 
    280273    } 
    281     out.write(extraArray); 
     274    out.write(extraBuf.getByteBuffer()); 
    282275    return numBytes; 
    283276  } 
  • branches/cleanup/components/bio-formats/src/loci/formats/tiff/TiffSaver.java

    r5862 r5877  
    385385        writeIFDValue(ifdOut, extraOut, oldOffset, tag, value, 
    386386          bigTiff); 
    387         // FIXME: BEGIN block to review for Stream --> Stream "buffered". 
    388387        ifdBuf.seek(0); 
    389         byte[] bytes = new byte[(int) ifdBuf.length()]; 
    390         ifdBuf.read(bytes); 
    391388        extraBuf.seek(0); 
    392         byte[] extra = new byte[(int) extraBuf.length()]; 
    393         extraBuf.read(extra); 
    394         // END block to review 
    395389 
    396390        // extract new directory entry parameters 
    397         int newTag = DataTools.bytesToInt(bytes, 0, 2, little); 
    398         int newType = DataTools.bytesToInt(bytes, 2, 2, little); 
     391        int newTag = ifdBuf.readShort(); 
     392        int newType = ifdBuf.readShort(); 
    399393        int newCount; 
    400394        long newOffset; 
    401395        if (bigTiff) { 
    402396          newCount = 
    403             (int) (DataTools.bytesToLong(bytes, 4, little) & 0xffffffff); 
    404           newOffset = DataTools.bytesToLong(bytes, 12, little); 
    405         } 
    406         else { 
    407           newCount = DataTools.bytesToInt(bytes, 4, little); 
    408           newOffset = DataTools.bytesToInt(bytes, 8, little); 
     397            (int) (ifdBuf.readInt() & 0xffffffff); 
     398          newOffset = ifdBuf.readLong(); 
     399        } 
     400        else { 
     401          newCount = ifdBuf.readInt(); 
     402          newOffset = ifdBuf.readInt(); 
    409403        } 
    410404        LOGGER.debug("overwriteIFDValue:"); 
     
    415409 
    416410        // determine the best way to overwrite the old entry 
    417         if (extra.length == 0) { 
     411        if (extraBuf.length() == 0) { 
    418412          // new entry is inline; if old entry wasn't, old data is orphaned 
    419413          // do not override new offset value since data is inline 
     
    451445        if (bigTiff) out.writeLong(newOffset); 
    452446        else out.writeInt((int) newOffset); 
    453         if (extra.length > 0) { 
     447        if (extraBuf.length() > 0) { 
    454448          out.seek(newOffset); 
    455           out.write(extra); 
     449          out.write(extraBuf.getByteBuffer()); 
    456450        } 
    457451        return; 
  • branches/cleanup/components/common/src/loci/common/ByteArrayHandle.java

    r5876 r5877  
    8787  } 
    8888 
     89  /** 
     90   * Gets the byte buffer backing this handle. <b>NOTE:</b> This is the 
     91   * backing buffer. Any modifications to this buffer including position, 
     92   * length and capacity will affect subsequent calls upon its source handle. 
     93   * @return Backing buffer of this handle. 
     94   */ 
     95  public ByteBuffer getByteBuffer() { 
     96    return buffer; 
     97  } 
     98 
    8999  // -- AbstractNIOHandle API methods -- 
    90100 
Note: See TracChangeset for help on using the changeset viewer.