Changeset 6680


Ignore:
Timestamp:
07/09/10 09:48:47 (9 years ago)
Author:
curtis
Message:

Backport r6679 to 4.2 branch.

Location:
branches/4.2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

    • Property svn:mergeinfo changed
      /trunkmerged: 6679
  • branches/4.2/components/bio-formats/src/loci/formats/ChannelFiller.java

    r6663 r6680  
    5757  protected Boolean filled = null; 
    5858 
     59  /** Number of LUT components. */ 
     60  protected int lutLength; 
     61 
    5962  // -- Constructors -- 
    6063 
     
    7073  public boolean isFilled() { 
    7174    if (!reader.isIndexed()) return false; // cannot fill non-indexed color 
     75    if (lutLength < 1) return false; // cannot fill when LUTs are missing 
    7276    return filled == null ? !reader.isFalseColor() : filled; 
    7377  } 
     
    8488  public int getSizeC() { 
    8589    if (!isFilled()) return reader.getSizeC(); 
    86     return reader.getSizeC() * getLookupTableComponentCount(); 
     90    return reader.getSizeC() * lutLength; 
    8791  } 
    8892 
     
    126130    // append filled dimension to channel dim lengths 
    127131    int[] newLengths = new int[1 + cLengths.length]; 
    128     newLengths[0] = getLookupTableComponentCount(); 
     132    newLengths[0] = lutLength; 
    129133    System.arraycopy(cLengths, 0, newLengths, 1, cLengths.length); 
    130134    return newLengths; 
     
    239243  public void setId(String id) throws FormatException, IOException { 
    240244    super.setId(id); 
     245    lutLength = getLookupTableComponentCount(); 
    241246    MetadataStore store = getMetadataStore(); 
    242247    MetadataTools.populatePixels(store, this, false, false); 
     
    246251 
    247252  /** Gets the number of color components in the lookup table. */ 
    248   private int getLookupTableComponentCount() { 
    249     try { 
    250       byte[][] lut8 = reader.get8BitLookupTable(); 
    251       if (lut8 != null) return lut8.length; 
    252       short[][] lut16 = reader.get16BitLookupTable(); 
    253       if (lut16 != null) return lut16.length; 
    254     } 
    255     catch (FormatException exc) { } 
    256     catch (IOException exc) { } 
    257     return 3; 
     253  private int getLookupTableComponentCount() 
     254    throws FormatException, IOException 
     255  { 
     256    byte[][] lut8 = reader.get8BitLookupTable(); 
     257    if (lut8 != null) return lut8.length; 
     258    short[][] lut16 = reader.get16BitLookupTable(); 
     259    if (lut16 != null) return lut16.length; 
     260    // NB: For some formats, LUTs are plane-specific and will 
     261    // only be available after opening a particular image plane. 
     262    reader.openBytes(0, 0, 0, 1, 1); // read a single pixel, for performance 
     263    lut8 = reader.get8BitLookupTable(); 
     264    if (lut8 != null) return lut8.length; 
     265    lut16 = reader.get16BitLookupTable(); 
     266    if (lut16 != null) return lut16.length; 
     267    return 0; // LUTs are missing 
    258268  } 
    259269 
  • branches/4.2/components/bio-formats/src/loci/formats/ImageTools.java

    r6663 r6680  
    162162    for (int i=0; i<rtn.length; i++) { 
    163163      byte[] a = new byte[4]; 
    164       for (int j=c-1; j>=0; j--) { 
     164      int maxC = Math.min(c, a.length); 
     165      for (int j=maxC-1; j>=0; j--) { 
    165166        a[j] = b[interleaved ? i + j * w * h : i * c + j]; 
    166167      } 
  • branches/4.2/components/bio-formats/src/loci/formats/gui/AWTImageTools.java

    r6663 r6680  
    6666import loci.formats.MetadataTools; 
    6767import loci.formats.meta.MetadataRetrieve; 
    68  
    6968import ome.xml.model.primitives.PositiveInteger; 
    7069 
     
    561560    boolean interleaved) 
    562561  { 
     562    int cc = Math.min(c, 4); // throw away channels beyond 4 
    563563    int[] buf = new int[data.length / c]; 
    564     int nBits = (c - 1) * 8; 
     564    int nBits = (cc - 1) * 8; 
    565565 
    566566    for (int i=0; i<buf.length; i++) { 
    567       for (int q=0; q<c; q++) { 
     567      for (int q=0; q<cc; q++) { 
    568568        if (interleaved) { 
    569569          buf[i] |= ((data[i*c + q] & 0xff) << (nBits - q*8)); 
     
    576576 
    577577    DataBuffer buffer = new DataBufferInt(buf, buf.length); 
    578     return constructImage(c, DataBuffer.TYPE_INT, w, h, false, false, buffer); 
     578    return constructImage(cc, DataBuffer.TYPE_INT, w, h, false, false, buffer); 
    579579  } 
    580580 
     
    638638    int h, boolean interleaved, boolean banded, DataBuffer buffer) 
    639639  { 
     640    if (c > 4) { 
     641      throw new IllegalArgumentException( 
     642        "Cannot construct image with " + c + " channels"); 
     643    } 
    640644    ColorModel colorModel = makeColorModel(c, type); 
    641645    if (colorModel == null) return null; 
     
    644648        colorModel = new UnsignedIntColorModel(32, type, c); 
    645649      } 
    646       catch (IOException e) { } 
     650      catch (IOException e) { 
     651        return null; 
     652      } 
    647653    } 
    648654 
     
    753759    BufferedImage b = makeImage(buf, w, h, indexed ? 1 : rgbChanCount, 
    754760      interleaved, bpp, false, little, signed); 
     761    if (b == null) { 
     762      throw new FormatException("Could not construct BufferedImage"); 
     763    } 
    755764 
    756765    if (indexed) { 
     
    10151024   */ 
    10161025  public static int getPixelType(BufferedImage image) { 
    1017     DataBuffer buffer = image.getRaster().getDataBuffer(); 
     1026    final Raster raster = image.getRaster(); 
     1027    if (raster == null) return -1; 
     1028    final DataBuffer buffer = raster.getDataBuffer(); 
     1029    if (buffer == null) return -1; 
    10181030 
    10191031    if (buffer instanceof SignedByteBuffer) { 
  • branches/4.2/components/bio-formats/src/loci/formats/tools/ImageInfo.java

    r6304 r6680  
    173173        else if (args[i].equals("-autoscale")) autoscale = true; 
    174174        else if (args[i].equals("-debug")) { 
     175          LOGGER.warn(""); 
    175176          LOGGER.warn("To enable debugging, edit the log4j.properties file,"); 
    176177          LOGGER.warn("changing log4j.rootCategory from INFO to DEBUG"); 
     
    373374      reader.getPixelType() == FormatTools.DOUBLE)) 
    374375    { 
     376      LOGGER.warn(""); 
    375377      LOGGER.warn("Java does not support " + 
    376378        "display of unnormalized floating point data."); 
     
    380382 
    381383    if (reader.isRGB() && reader.getRGBChannelCount() > 4) { 
     384      LOGGER.warn(""); 
    382385      LOGGER.warn("Java does not support merging more than 4 channels."); 
    383386      LOGGER.warn("Please use the '-separate' option " + 
    384         "to avoid receiving a cryptic exception."); 
     387        "to avoid losing channels beyond the 4th."); 
    385388    } 
    386389  } 
     
    752755          sizeX, sizeY, FormatTools.isSigned(pixelType)); 
    753756      } 
    754  
     757      if (images[i - start] == null) { 
     758        LOGGER.warn("\t************ Failed to read plane #{} ************", i); 
     759      } 
    755760      if (reader.isIndexed() && reader.get8BitLookupTable() == null && 
    756761        reader.get16BitLookupTable() == null) 
    757762      { 
    758         LOGGER.info(NEWLINE); 
    759763        LOGGER.warn("\t************ no LUT for plane #{} ************", i); 
    760764      } 
  • branches/4.2/components/loci-plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Calibrator.java

  • branches/4.2/components/ome-xml

Note: See TracChangeset for help on using the changeset viewer.