Changeset 6991


Ignore:
Timestamp:
09/28/10 10:29:46 (9 years ago)
Author:
melissa
Message:

Merged r6695 into 4.2.

Location:
branches/4.2/components/bio-formats/src/loci/formats/in
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/bio-formats/src/loci/formats/in

  • branches/4.2/components/bio-formats/src/loci/formats/in/AmiraReader.java

    r6663 r6991  
    397397    int[] internalOffsets; 
    398398    int currentNo, maxOffsetIndex, planeSize; 
     399    long lastCodeOffset = 0; 
    399400 
    400401    HxRLE(int sliceCount, long compressedSize) { 
     
    411412      int off = 0; 
    412413      while (len > 0 && in.getFilePointer() < in.length()) { 
     414        lastCodeOffset = in.getFilePointer(); 
    413415        int insn = in.readByte(); 
    414416        if (insn < 0) { 
     
    427429        else { 
    428430          if (insn > len) { 
    429             internalOffsets[currentNo] = insn - len; 
     431            internalOffsets[currentNo] = len; 
    430432            insn = len; 
    431433          } 
    432           if (off == 0 && internalOffsets[currentNo - 1] > 0) { 
    433             insn = internalOffsets[currentNo - 1]; 
     434          else if (insn == len) lastCodeOffset += 2; 
     435          if (off == 0 && currentNo > 0 && internalOffsets[currentNo - 1] > 0) { 
     436            insn -= internalOffsets[currentNo - 1]; 
    434437          } 
    435438          Arrays.fill(buf, off, off + insn, in.readByte()); 
     
    442445    public byte[] read(int no, byte[] buf) throws FormatException, IOException { 
    443446      if (maxOffsetIndex < no) { 
    444         if (currentNo != maxOffsetIndex) { 
    445           in.seek(offsets[maxOffsetIndex]); 
    446         } 
    447         currentNo = no + 1; 
     447        in.seek(offsets[maxOffsetIndex]); 
    448448        while (maxOffsetIndex < no) { 
    449449          read(buf, planeSize); 
    450           offsets[++maxOffsetIndex] = in.getFilePointer(); 
     450          currentNo = no + 1; 
     451          offsets[++maxOffsetIndex] = lastCodeOffset; 
    451452        } 
    452453      } 
    453454      else { 
    454         if (currentNo != no) { 
    455           in.seek(offsets[no]); 
    456         } 
     455        in.seek(offsets[no]); 
     456        read(buf, planeSize); 
    457457        currentNo = no + 1; 
    458         read(buf, planeSize); 
    459458        if (maxOffsetIndex == no) { 
    460           offsets[++maxOffsetIndex] = in.getFilePointer(); 
     459          offsets[++maxOffsetIndex] = lastCodeOffset; 
    461460        } 
    462461      } 
Note: See TracChangeset for help on using the changeset viewer.