Changeset 3389


Ignore:
Timestamp:
11/19/07 14:33:40 (12 years ago)
Author:
melissa
Message:

Automatically apply the LUT, instead of having isIndexed() return true; there was a weird problem with opening indexed AVIs in ImageJ.

File:
1 edited

Legend:

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

    r3354 r3389  
    7070 
    7171  private byte[] lastImage; 
     72  private int lastImageNo; 
    7273 
    7374  // -- Constructor -- 
     
    8182  public boolean isThisType(byte[] block) { 
    8283    return new String(block).startsWith("RIFF"); 
    83   } 
    84  
    85   /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    86   public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    87     FormatTools.assertId(currentId, true, 1); 
    88     return lut; 
    8984  } 
    9085 
     
    170165    lut = null; 
    171166    lastImage = null; 
     167    lastImageNo = -1; 
    172168  } 
    173169 
     
    185181    offsets = new Vector(); 
    186182    lengths = new Vector(); 
     183    lastImageNo = -1; 
    187184 
    188185    String listString; 
     
    457454 
    458455    core.rgb[0] = bmpBitsPerPixel > 8 || (bmpCompression != 0); 
     456    core.indexed[0] = false; 
    459457    core.sizeZ[0] = 1; 
    460     core.sizeC[0] = core.rgb[0] ? 3 : 1; 
    461458    core.sizeT[0] = core.imageCount[0]; 
    462     core.currentOrder[0] = core.sizeC[0] == 3 ? "XYCTZ" : "XYTCZ"; 
    463459    core.littleEndian[0] = true; 
    464460    core.interleaved[0] = bmpBitsPerPixel != 16; 
    465     core.indexed[0] = bmpBitsPerPixel == 8 && bmpCompression != 0; 
     461    core.sizeC[0] = core.rgb[0] ? 3 : 1; 
     462    core.currentOrder[0] = core.sizeC[0] == 3 ? "XYCTZ" : "XYTCZ"; 
    466463    core.falseColor[0] = false; 
    467464    core.metadataComplete[0] = true; 
     
    500497    if (bmpCompression == MSRLE) { 
    501498      Object[] options = new Object[2]; 
    502       options[1] = lastImage; 
     499      options[1] = (lastImageNo == no - 1) ? lastImage : null; 
    503500      options[0] = new int[] {core.sizeX[0], core.sizeY[0]}; 
    504501      MSRLECodec codec = new MSRLECodec(); 
    505502      buf = codec.decompress(b, options); 
    506503      lastImage = buf; 
    507       if (no == core.imageCount[0] - 1) lastImage = null; 
    508       return buf; 
     504      lastImageNo = no; 
    509505    } 
    510506    else if (bmpCompression == MS_VIDEO) { 
     
    513509      options[1] = new Integer(core.sizeX[0]); 
    514510      options[2] = new Integer(core.sizeY[0]); 
    515       options[3] = lastImage; 
     511      options[3] = (lastImageNo == no - 1) ? lastImage : null; 
    516512 
    517513      MSVideoCodec codec = new MSVideoCodec(); 
    518514      buf = codec.decompress(b, options); 
    519515      lastImage = buf; 
    520       if (no == core.imageCount[0] - 1) lastImage = null; 
    521       return buf; 
     516      lastImageNo = no; 
    522517    } 
    523518    /* 
     
    534529    } 
    535530    */ 
    536     throw new FormatException("Unsupported compression : " + bmpCompression); 
     531    else { 
     532      throw new FormatException("Unsupported compression : " + bmpCompression); 
     533    } 
     534    b = buf; 
     535    buf = new byte[b.length * core.sizeC[0]]; 
     536    for (int i=0; i<b.length; i++) { 
     537      buf[i*core.sizeC[0]] = lut[0][b[i] & 0xff]; 
     538      buf[i*core.sizeC[0] + 1] = lut[1][b[i] & 0xff]; 
     539      buf[i*core.sizeC[0] + 2] = lut[2][b[i] & 0xff]; 
     540    } 
     541    return buf; 
    537542  } 
    538543 
Note: See TracChangeset for help on using the changeset viewer.