Changeset 6799


Ignore:
Timestamp:
08/16/10 14:23:49 (9 years ago)
Author:
melissa
Message:

Fixed a few Bio-Rad Gel offset bugs.

File:
1 edited

Legend:

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

    r6655 r6799  
    4646 
    4747  private static final long PIXEL_OFFSET = 59654; 
     48  private static final long BIG_ENDIAN_OFFSET = 348; 
     49  private static final long LITTLE_ENDIAN_OFFSET = 268; 
    4850 
    4951  // -- Fields -- 
     
    7779    FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); 
    7880 
     81    int planeSize = FormatTools.getPlaneSize(this); 
     82 
    7983    if (offset > PIXEL_OFFSET) { 
    8084      in.seek(offset + 1285); 
    8185    } 
    82     else in.seek(PIXEL_OFFSET); 
     86    else if (PIXEL_OFFSET + planeSize <= in.length()) { 
     87      in.seek(PIXEL_OFFSET); 
     88    } 
     89    else in.seek(in.length() - planeSize); 
    8390 
    8491    int bpp = FormatTools.getBytesPerPixel(getPixelType()); 
     
    103110    in = new RandomAccessInputStream(id); 
    104111 
    105     in.seek(348); 
     112    String check = in.readString(48); 
     113    if (check.indexOf("Intel Format") != -1) { 
     114      in.order(true); 
     115    } 
     116 
     117    long headerOffset = 
     118      in.isLittleEndian() ? LITTLE_ENDIAN_OFFSET : BIG_ENDIAN_OFFSET; 
     119 
     120    in.seek(headerOffset); 
    106121    int skip = in.readInt() - 28; 
     122    headerOffset = BIG_ENDIAN_OFFSET; 
    107123 
    108124    double physicalWidth = 0d, physicalHeight = 0d; 
    109125    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { 
    110       in.seek(348 + skip - 8187); 
     126      in.seek(headerOffset + skip - 8187); 
    111127      String scannerName = in.readCString(); 
    112128      in.skipBytes(8); 
     
    129145    } 
    130146 
    131     in.seek(348 + skip - 273); 
     147    in.seek(headerOffset + skip - 273); 
    132148    String date = in.readCString(); 
    133149    date = DateTools.formatDate(date, "dd-MMM-yyyy HH:mm"); 
    134150 
    135     in.seek(348 + skip); 
     151    in.seek(headerOffset + skip); 
    136152 
    137153    core[0].sizeX = in.readShort() & 0xffff; 
Note: See TracChangeset for help on using the changeset viewer.