Changeset 6021 for branches/cleanup


Ignore:
Timestamp:
03/11/10 11:45:16 (10 years ago)
Author:
melissa
Message:
  • Readded lookup table support to TiffWriter.
  • Fixed a couple of bugs in saving little-endian TIFFs.
Location:
branches/cleanup/components
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/src/loci/formats/gui/AWTImageTools.java

    r5958 r6021  
    17241724  } 
    17251725 
     1726  /** Converts an IndexColorModel to a 2D byte array. */ 
     1727  public static byte[][] get8BitLookupTable(ColorModel model) { 
     1728    if (!(model instanceof IndexColorModel)) return null; 
     1729    IndexColorModel m = (IndexColorModel) model; 
     1730    byte[][] lut = new byte[3][m.getMapSize()]; 
     1731    m.getReds(lut[0]); 
     1732    m.getGreens(lut[1]); 
     1733    m.getBlues(lut[2]); 
     1734    return lut; 
     1735  } 
     1736 
     1737  /** Convers an Index16ColorModel to a 2D short array. */ 
     1738  public static short[][] getLookupTable(ColorModel model) { 
     1739    if (!(model instanceof Index16ColorModel)) return null; 
     1740    Index16ColorModel m = (Index16ColorModel) model; 
     1741    short[][] lut = new short[3][]; 
     1742    lut[0] = m.getReds(); 
     1743    lut[1] = m.getGreens(); 
     1744    lut[2] = m.getBlues(); 
     1745    return lut; 
     1746  } 
     1747 
    17261748} 
  • branches/cleanup/components/bio-formats/src/loci/formats/gui/Index16ColorModel.java

    r5191 r6021  
    7272  } 
    7373 
     74  // -- Index16ColorModel API methods -- 
     75 
     76  /** Return the array of red color components. */ 
     77  public short[] getReds() { 
     78    return redShort; 
     79  } 
     80 
     81  /** Return the array of green color components. */ 
     82  public short[] getGreens() { 
     83    return greenShort; 
     84  } 
     85 
     86  /** Return the array of blue color components. */ 
     87  public short[] getBlues() { 
     88    return blueShort; 
     89  } 
     90 
     91  /** Return the array of alpha color components. */ 
     92  public short[] getAlphas() { 
     93    return alphaShort; 
     94  } 
     95 
    7496  // -- ColorModel API methods -- 
    7597 
  • branches/cleanup/components/bio-formats/src/loci/formats/out/TiffWriter.java

    r6020 r6021  
    3434import loci.formats.ImageTools; 
    3535import loci.formats.MetadataTools; 
     36import loci.formats.gui.AWTImageTools; 
    3637import loci.formats.meta.MetadataRetrieve; 
    3738import loci.formats.tiff.IFD; 
     
    161162    } 
    162163 
     164    byte[][] lut = AWTImageTools.get8BitLookupTable(cm); 
     165    if (lut != null) { 
     166      int[] colorMap = new int[lut.length * lut[0].length]; 
     167      for (int i=0; i<lut.length; i++) { 
     168        for (int j=0; j<lut[0].length; j++) { 
     169          colorMap[i * lut[0].length + j] = (int) ((lut[i][j] & 0xff) << 8); 
     170        } 
     171      } 
     172      ifd.putIFDValue(IFD.COLOR_MAP, colorMap); 
     173    } 
     174 
    163175    ifd.put(new Integer(IFD.IMAGE_WIDTH), new Integer(width)); 
    164176    ifd.put(new Integer(IFD.IMAGE_LENGTH), new Integer(height)); 
  • branches/cleanup/components/bio-formats/src/loci/formats/tiff/TiffSaver.java

    r6020 r6021  
    292292    throws FormatException, IOException 
    293293  { 
     294    extraOut.order(isLittleEndian()); 
     295 
    294296    // convert singleton objects into arrays, for simplicity 
    295297    if (value instanceof Short) { 
  • branches/cleanup/components/common/src/loci/common/NIOFileHandle.java

    r5897 r6021  
    7878  protected FileChannel.MapMode mapMode = FileChannel.MapMode.READ_ONLY; 
    7979 
     80  /** The buffer's byte ordering. */ 
     81  protected ByteOrder order; 
     82 
    8083  // -- Constructors -- 
    8184 
     
    157160  /* @see IRandomAccess.setOrder(ByteOrder) */ 
    158161  public void setOrder(ByteOrder order) { 
     162    this.order = order; 
    159163    buffer.order(order); 
    160164  } 
     
    466470      long newSize = Math.min(length() - bufferStartPosition, bufferSize); 
    467471      if (newSize < size && newSize == bufferSize) newSize = size; 
    468       ByteOrder order = buffer == null ? null : getOrder(); 
     472      ByteOrder byteOrder = buffer == null ? order : getOrder(); 
    469473      buffer = channel.map(mapMode, bufferStartPosition, newSize); 
    470       if (order != null) setOrder(order); 
     474      if (byteOrder != null) setOrder(byteOrder); 
    471475    } 
    472476    buffer.position((int) (offset - bufferStartPosition)); 
Note: See TracChangeset for help on using the changeset viewer.