Changeset 7141


Ignore:
Timestamp:
10/27/10 21:31:32 (9 years ago)
Author:
melissa
Message:
  • Backported r6227 to 4.1.
  • Fixed a subtle bug in calculating the pixel data offset for PSD files with no layers.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/components/bio-formats/src/loci/formats/in/PSDReader.java

    r6767 r7141  
    272272        } 
    273273      } 
    274       while (in.read() != '8'); 
    275       in.skipBytes(7); 
     274      if (layerCount > 0) { 
     275        while (in.read() != '8'); 
     276        in.skipBytes(7); 
     277      } 
    276278      int len = in.readInt(); 
    277279      if ((len % 4) != 0) len += 4 - (len % 4); 
  • branches/4.1/components/common/src/loci/common/RandomAccessInputStream.java

    r6919 r7141  
    421421  /** Read a string of length n. */ 
    422422  public String readString(int n) throws IOException { 
     423    int avail = available(); 
     424    if (n > avail) n = avail; 
    423425    byte[] b = new byte[n]; 
    424426    readFully(b); 
     
    453455  /** Skip n bytes within the stream. */ 
    454456  public int skipBytes(int n) throws IOException { 
     457    if (n < 0) return 0; 
    455458    afp += n; 
    456459    return n; 
     
    540543  public int available() throws IOException { 
    541544    if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    542     int available = dis != null ? dis.available() + ext : 
    543       (int) (length() - getFilePointer()); 
    544     if (available < 0) available = Integer.MAX_VALUE; 
    545     return available; 
     545    long remain = length() - getFilePointer(); 
     546    if (remain > Integer.MAX_VALUE) remain = Integer.MAX_VALUE; 
     547    return (int) remain; 
    546548  } 
    547549 
  • branches/4.2/components/bio-formats/src/loci/formats/in/PSDReader.java

    r7007 r7141  
    269269        } 
    270270      } 
    271       while (in.read() != '8'); 
    272       in.skipBytes(7); 
     271      if (layerCount > 0) { 
     272        while (in.read() != '8'); 
     273        in.skipBytes(7); 
     274      } 
    273275      int len = in.readInt(); 
    274276      if ((len % 4) != 0) len += 4 - (len % 4); 
  • trunk/components/bio-formats/src/loci/formats/in/PSDReader.java

    r6881 r7141  
    269269        } 
    270270      } 
    271       while (in.read() != '8'); 
    272       in.skipBytes(7); 
     271      if (layerCount > 0) { 
     272        while (in.read() != '8'); 
     273        in.skipBytes(7); 
     274      } 
    273275      int len = in.readInt(); 
    274276      if ((len % 4) != 0) len += 4 - (len % 4); 
Note: See TracChangeset for help on using the changeset viewer.