Changeset 4702


Ignore:
Timestamp:
12/23/08 10:16:48 (11 years ago)
Author:
melissa
Message:

Fix for 16-bit grayscale AVIs; closes #335.

File:
1 edited

Legend:

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

    r4681 r4702  
    6363  private int size = -1; 
    6464  private long pos; 
     65  private int bytesPerPlane; 
    6566 
    6667  // Stream Format chunk fields 
     
    186187    } 
    187188 
    188     if (bmpBitsPerPixel == 16) { 
    189       // channels are separated, need to swap them 
     189    if (bmpBitsPerPixel == 16 && isRGB()) { 
     190      // channels are stored as BGR, need to swap them 
    190191      byte[] r = new byte[getSizeX() * getSizeY() * 2]; 
    191192      System.arraycopy(buf, 2 * (buf.length / 3), r, 0, r.length); 
     
    327328 
    328329                addMeta("Stream quality", in.readInt()); 
    329                 addMeta("Stream sample size", in.readInt()); 
     330                bytesPerPlane = in.readInt(); 
     331                addMeta("Stream sample size", bytesPerPlane); 
    330332 
    331333                if (spos + size <= in.length()) { 
     
    489491        else { 
    490492          // skipping unknown block 
    491           try { 
    492             in.skipBytes(8 + size); 
    493           } 
    494           catch (IllegalArgumentException iae) { } 
     493          if (size + 8 >= 0) in.skipBytes(8 + size); 
    495494        } 
    496495      } 
     
    509508    core[0].imageCount = offsets.size(); 
    510509 
    511     core[0].rgb = (bmpBitsPerPixel > 8 || (bmpCompression != 0)) && lut == null; 
    512510    core[0].indexed = lut != null; 
    513511    core[0].sizeZ = 1; 
     
    515513    core[0].littleEndian = true; 
    516514    core[0].interleaved = bmpBitsPerPixel != 16; 
    517     core[0].sizeC = isRGB() ? 3 : 1; 
     515    if (bytesPerPlane == 0 || bmpBitsPerPixel == 24) { 
     516      core[0].rgb = 
     517        (bmpBitsPerPixel > 8 || (bmpCompression != 0)) && lut == null; 
     518      core[0].sizeC = isRGB() ? 3 : 1; 
     519    } 
     520    else { 
     521      core[0].sizeC = bytesPerPlane / 
     522        (getSizeX() * getSizeY() * (bmpBitsPerPixel / 8)); 
     523      core[0].rgb = getSizeC() > 1; 
     524    } 
    518525    core[0].dimensionOrder = getSizeC() == 3 ? "XYCTZ" : "XYTCZ"; 
    519526    core[0].falseColor = false; 
Note: See TracChangeset for help on using the changeset viewer.