Changeset 7318


Ignore:
Timestamp:
12/03/10 16:28:43 (9 years ago)
Author:
melissa
Message:

ImageTools.splitChannels now takes an extra int parameter that specifies the number of bytes in a single split channel.

This fixes a number of problems that occur when the buffer passed to openBytes is larger than the size of the desired tile (as is the case in several of the tests in OmeroOpenBytesTest).

Location:
trunk/components/bio-formats/src/loci/formats
Files:
5 edited

Legend:

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

    r6881 r7318  
    121121  public boolean isRGB() { 
    122122    FormatTools.assertId(getCurrentFile(), true, 2); 
    123     return isIndexed() && !isFalseColor(); 
     123    return isIndexed() && !isFalseColor() && getSizeC() > 1; 
    124124  } 
    125125 
     
    193193 
    194194          ImageTools.splitChannels(lastImage, strip, channel, c, bpp, 
    195             false, isInterleaved()); 
     195            false, isInterleaved(), strip.length); 
    196196          if (strips != 1) { 
    197197            System.arraycopy(strip, 0, buf, i * stripHeight * w * bpp, 
     
    202202      else { 
    203203        ImageTools.splitChannels(lastImage, buf, channel, c, bpp, 
    204           false, isInterleaved()); 
     204          false, isInterleaved(), w * h * bpp); 
    205205      } 
    206206 
  • trunk/components/bio-formats/src/loci/formats/ImageTools.java

    r7256 r7318  
    191191    boolean reverse, boolean interleaved) 
    192192  { 
    193     return splitChannels(array, null, index, c, bytes, reverse, interleaved); 
     193    return splitChannels(array, null, index, c, bytes, reverse, interleaved, 
     194      array.length / c); 
    194195  } 
    195196 
     
    199200   * channels are in BGR order.  If the 'rtn' parameter is not null, the 
    200201   * specified channel will be copied into 'rtn'. 
     202   * 
     203   * The 'channelLength' parameter specifies the number of bytes that are 
     204   * expected to be in a single channel.  In many cases, this will match 
     205   * the value of 'rtn.length', but specifying it separately allows 'rtn' to 
     206   * be larger than the size of a single channel. 
    201207   */ 
    202208  public static byte[] splitChannels(byte[] array, byte[] rtn, int index, int c, 
    203     int bytes, boolean reverse, boolean interleaved) 
     209    int bytes, boolean reverse, boolean interleaved, int channelLength) 
    204210  { 
    205211    if (c == 1) return array; 
    206     if (rtn == null) rtn = new byte[array.length / c]; 
     212    if (rtn == null) { 
     213      rtn = new byte[array.length / c]; 
     214    } 
    207215 
    208216    if (reverse) index = c - index - 1; 
    209217 
    210218    if (!interleaved) { 
    211       System.arraycopy(array, rtn.length * index, rtn, 0, rtn.length); 
     219      System.arraycopy(array, channelLength * index, rtn, 0, channelLength); 
    212220    } 
    213221    else { 
  • trunk/components/bio-formats/src/loci/formats/in/AmiraReader.java

    r6881 r7318  
    8888 
    8989      // plane readers can only read whole planes, so we need to blit 
    90       int bytesPerPixel = FormatTools.getBytesPerPixel(core[series].pixelType); 
     90      int bytesPerPixel = FormatTools.getBytesPerPixel(getPixelType()); 
    9191      byte[] planeBuf = new byte[planeSize]; 
    9292      planeReader.read(no, planeBuf); 
  • trunk/components/bio-formats/src/loci/formats/in/SimplePCITiffReader.java

    r6805 r7318  
    105105    int c = getZCTCoords(no)[1]; 
    106106    ImageTools.splitChannels( 
    107       b, buf, c, getSizeC(), bpp, false, isInterleaved()); 
     107      b, buf, c, getSizeC(), bpp, false, isInterleaved(), w * h * bpp); 
    108108    return buf; 
    109109  } 
  • trunk/components/bio-formats/src/loci/formats/in/ZeissLSMReader.java

    r7311 r7318  
    328328        prevRegion = region; 
    329329      } 
    330       ImageTools.splitChannels(prevBuf, buf, c, getSizeC(), bpp, false, false); 
     330      ImageTools.splitChannels( 
     331        prevBuf, buf, c, getSizeC(), bpp, false, false, w * h * bpp); 
    331332    } 
    332333    else { 
Note: See TracChangeset for help on using the changeset viewer.