Changeset 7355


Ignore:
Timestamp:
12/07/10 17:01:18 (9 years ago)
Author:
melissa
Message:

Fixed a handful of problems with reading Amira sub-images.

File:
1 edited

Legend:

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

    r7318 r7355  
    7373  // -- IFormatReader API methods -- 
    7474 
    75   /* (non-Javadoc) 
     75  /** 
    7676   * @see loci.formats.FormatReader#openBytes(int, byte[], int, int, int, int) 
    7777   */ 
     
    8383    int planeSize = FormatTools.getPlaneSize(this); 
    8484    if (planeReader != null) { 
    85       if (x == 0 && y == 0 && w == parameters.width && h == parameters.height) { 
    86         return planeReader.read(no, buf); 
    87       } 
    88  
    8985      // plane readers can only read whole planes, so we need to blit 
    9086      int bytesPerPixel = FormatTools.getBytesPerPixel(getPixelType()); 
    9187      byte[] planeBuf = new byte[planeSize]; 
    9288      planeReader.read(no, planeBuf); 
     89      int srcWidth = parameters.width * bytesPerPixel; 
     90      int destWidth = w * bytesPerPixel; 
    9391      for (int j = y; j < y + h; j++) { 
    94         System.arraycopy(planeBuf, (x + j * parameters.width) * bytesPerPixel, 
    95           buf, (j - y) * w * bytesPerPixel, w * bytesPerPixel); 
     92        int src = j * srcWidth + x * bytesPerPixel; 
     93        int dest = (j - y) * destWidth; 
     94        System.arraycopy(planeBuf, src, buf, dest, destWidth); 
    9695      } 
    9796    } 
     
    388387  /** 
    389388   * This is the reader for RLE-compressed AmiraMeshes. 
    390    * 
    391    * Amira expects the RLE-compressed stream to be aligned with the slices. 
    392    * In other words, the RLE stream must restart at each slice start. 
    393389   */ 
    394390  class HxRLE implements PlaneReader { 
     
    447443        in.seek(offsets[maxOffsetIndex]); 
    448444        while (maxOffsetIndex < no) { 
     445          currentNo = no; 
    449446          read(buf, planeSize); 
    450           currentNo = no + 1; 
    451447          offsets[++maxOffsetIndex] = lastCodeOffset; 
    452448        } 
     
    454450      else { 
    455451        in.seek(offsets[no]); 
     452        currentNo = no; 
    456453        read(buf, planeSize); 
    457         currentNo = no + 1; 
    458454        if (maxOffsetIndex == no) { 
    459455          offsets[++maxOffsetIndex] = lastCodeOffset; 
Note: See TracChangeset for help on using the changeset viewer.