Changeset 4309


Ignore:
Timestamp:
08/14/08 11:24:33 (12 years ago)
Author:
melissa
Message:

Fixed a couple of problems with snapshot (RGB) images.

File:
1 edited

Legend:

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

    r4300 r4309  
    7979    int bytes = FormatTools.getBytesPerPixel(getPixelType()); 
    8080    int bpp = bytes * getRGBChannelCount(); 
     81 
     82    long nextOffset = series + 1 < offsets.size() ? 
     83      ((Long) offsets.get(series + 1)).longValue() : in.length(); 
     84    int bytesToSkip = 
     85      (int) (nextOffset - offset - bpp * getSizeX() * getSizeY()); 
     86    bytesToSkip /= getSizeY(); 
     87    if ((getSizeX() % 2) == 0) bytesToSkip = 0; 
     88 
    8189    in.seek(offset + getSizeX() * getSizeY() * (long) no * bpp); 
    82     DataTools.readPlane(in, x, y, w, h, this, buf); 
     90    in.skipBytes(bytesToSkip * getSizeY() * no); 
     91 
     92    if (bytesToSkip == 0) { 
     93      DataTools.readPlane(in, x, y, w, h, this, buf); 
     94    } 
     95    else { 
     96      in.skipBytes(y * getSizeX() * bpp + y * bytesToSkip); 
     97      for (int row=0; row<h; row++) { 
     98        in.skipBytes(x * bpp); 
     99        in.read(buf, row * w * bpp, w * bpp); 
     100        in.skipBytes(bpp * (getSizeX() - w - x) + bytesToSkip); 
     101      } 
     102    } 
     103 
     104    // color planes are stored in BGR order 
     105    if (getRGBChannelCount() == 3) { 
     106      for (int i=0; i<buf.length; i+=bpp) { 
     107        for (int b=0; b<bytes; b++) { 
     108          byte tmp = buf[i + b]; 
     109          buf[i + b] = buf[i + bytes*2]; 
     110          buf[i + bytes*2] = tmp; 
     111        } 
     112      } 
     113    } 
    83114 
    84115    return buf; 
Note: See TracChangeset for help on using the changeset viewer.