Changeset 3161


Ignore:
Timestamp:
09/14/07 09:56:34 (12 years ago)
Author:
melissa
Message:

Fixed pixel type detection and offset calculation for zlib-compressed planes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/ND2Reader.java

    r3149 r3161  
    187187      byte[][] pixels = ImageTools.getPixelBytes(b, false); 
    188188      if (pixels.length == 1 && core.sizeC[0] > 1) { 
    189         pixels = ImageTools.splitChannels(pixels[0], core.sizeC[0],  
    190           FormatTools.getBytesPerPixel(core.pixelType[0]), false,  
     189        pixels = ImageTools.splitChannels(pixels[0], core.sizeC[0], 
     190          FormatTools.getBytesPerPixel(core.pixelType[0]), false, 
    191191          !core.interleaved[0]); 
    192192      } 
     
    200200      byte[] b = new byte[buf.length]; 
    201201      in.read(b); 
     202 
     203      if ((core.sizeX[0] % 2) != 0) { 
     204        buf = new byte[(core.sizeX[0] + 1) * core.sizeY[0] * 
     205          getRGBChannelCount() * 
     206          FormatTools.getBytesPerPixel(core.pixelType[0])]; 
     207      } 
     208 
    202209      Inflater decompresser = new Inflater(); 
    203210      decompresser.setInput(b); 
     
    205212      catch (DataFormatException e) { throw new FormatException(e); } 
    206213      decompresser.end(); 
     214 
     215      if ((core.sizeX[0] % 2) != 0) { 
     216        byte[] tmp = buf; 
     217        buf = new byte[core.sizeX[0] * core.sizeY[0] * getRGBChannelCount() * 
     218          FormatTools.getBytesPerPixel(core.pixelType[0])]; 
     219        int row = core.sizeX[0] * getRGBChannelCount() * 
     220          FormatTools.getBytesPerPixel(core.pixelType[0]); 
     221        int padRow = (core.sizeX[0] + 1) * getRGBChannelCount() * 
     222          FormatTools.getBytesPerPixel(core.pixelType[0]); 
     223        for (int i=0; i<core.sizeY[0]; i++) { 
     224          System.arraycopy(tmp, padRow * i, buf, row * i, row); 
     225        } 
     226      } 
    207227    } 
    208228    else in.readFully(buf); 
     
    364384      if (isLossless) { 
    365385        for (int i=0; i<offsets.length; i++) { 
    366           offsets[i] += i + 1; 
     386          offsets[i]++;  
    367387        } 
    368388      } 
     
    560580    core.sizeC[0] = img.getRaster().getNumBands(); 
    561581    core.rgb[0] = core.sizeC[0] > 1; 
     582    core.pixelType[0] = ImageTools.getPixelType(img); 
    562583 
    563584    int numInvalid = 0; 
     
    667688    } 
    668689 
    669     if (bits == 0) core.pixelType[0] = FormatTools.UINT8; 
    670     else { 
     690    if (bits != 0) { 
    671691      int bpp = bits; 
    672692      while (bpp % 8 != 0) bpp++; 
     
    800820      } 
    801821      else if (qName.equals("dCompressionParam")) { 
    802         isLossless = attributes.getValue("value").equals("1"); 
     822        isLossless = !attributes.getValue("value").equals("0"); 
    803823        addMeta(qName, attributes.getValue("value")); 
    804824      } 
Note: See TracChangeset for help on using the changeset viewer.