Changeset 4826


Ignore:
Timestamp:
02/19/09 21:18:02 (11 years ago)
Author:
melissa
Message:

Added fix for Openlab files whose pixel type does not match the pixel type of the inner PICT images (courtesy of Jim Paris).

File:
1 edited

Legend:

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

    r4750 r4826  
    4242 * @author Eric Kjellman egkjellman at wisc.edu 
    4343 * @author Curtis Rueden ctrueden at wisc.edu 
     44 * @author Jim Paris jim at jtan.com 
    4445 */ 
    4546public class OpenlabReader extends FormatReader { 
     
    194195        Location.mapFile("OPENLAB_PICT", new RABytes(b)); 
    195196        pict.setId("OPENLAB_PICT"); 
    196         pict.openBytes(0, tmpBuf, x, y, w, h); 
     197 
     198        if (FormatTools.getBytesPerPixel(pict.getPixelType()) == 2 && 
     199          FormatTools.getBytesPerPixel(getPixelType()) == 1) 
     200        { 
     201          // Pixel counts don't match -- e.g. the Openlab file said 8 bit 
     202          // grey, but the PICTs inside contained a 16-bit lookup table 
     203          // and we now have 48-bit RGB planar. 
     204          // Reduce to 8 bit grey (or 24 bit RGB) by dropping every other byte. 
     205          byte[] tmpBuf2 = new byte[tmpBuf.length * 2]; 
     206          pict.openBytes(0, tmpBuf2, x, y, w, h); 
     207          for (int i=0; i<tmpBuf.length; i++) { 
     208            tmpBuf[i] = tmpBuf2[i * 2]; 
     209          } 
     210        } 
     211        else if (getPixelType() != pict.getPixelType()) { 
     212          throw new FormatException("Pixel type of inner PICT does not match " + 
     213            "pixel type of Openlab file"); 
     214        } 
     215        else pict.openBytes(0, tmpBuf, x, y, w, h); 
     216 
    197217        if (getRGBChannelCount() == 1) { 
    198218          byte[] splitBuf = ImageTools.splitChannels(tmpBuf, 0, 3, 
Note: See TracChangeset for help on using the changeset viewer.