Changeset 2711


Ignore:
Timestamp:
05/01/07 11:23:01 (13 years ago)
Author:
curtis
Message:

Flex reader, using LuraWave decoding library.

Location:
trunk/loci/formats
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/TiffTools.java

    r2617 r2711  
    174174  public static final int THUNDERSCAN = 32809; 
    175175  public static final int NIKON = 34713; 
     176  public static final int LURAWAVE = -1; 
    176177 
    177178  // photometric interpretation types 
     
    10301031 
    10311032    // If the subsequent color maps are empty, use the first IFD's color map 
    1032     if (colorMap == null) 
     1033    if (colorMap == null) { 
    10331034      colorMap = getIFDIntArray(getFirstIFD(in), COLOR_MAP, false); 
     1035    } 
    10341036 
    10351037    // use special color map for YCbCr 
     
    11871189    } 
    11881190 
    1189     if (samplesPerPixel == 1 && (photoInterp == RGB_PALETTE || 
    1190       photoInterp == CFA_ARRAY)) 
     1191    if (samplesPerPixel == 1 && 
     1192      (photoInterp == RGB_PALETTE || photoInterp == CFA_ARRAY)) 
    11911193    { 
    11921194      samplesPerPixel = 3; 
     
    17711773    } 
    17721774    else if (compression == LZW) { 
    1773       LZWCodec c = new LZWCodec(); 
    1774       return c.decompress(input); 
    1775       // return Compression.lzwUncompress(input); 
     1775      return new LZWCodec().decompress(input); 
    17761776    } 
    17771777    else if (compression == JPEG) { 
     
    17791779        "Sorry, JPEG compression mode is not supported"); 
    17801780    } 
    1781     //else if (compression == NIKON) { 
    1782     //  return Compression.nikonUncompress(input); 
    1783     //} 
    1784     else if (compression == NIKON) { 
    1785       throw new FormatException("Sorry, Nikon compression mode is not " + 
    1786         "supported; it will be added in the near future"); 
    1787     } 
    17881781    else if (compression == PACK_BITS) { 
    1789       PackbitsCodec c = new PackbitsCodec(); 
    1790       return c.decompress(input); 
    1791  
    1792       //return Compression.packBitsUncompress(input); 
     1782      return new PackbitsCodec().decompress(input); 
    17931783    } 
    17941784    else if (compression == PROPRIETARY_DEFLATE || compression == DEFLATE) { 
    1795       //return Compression.deflateUncompress(input); 
    1796       AdobeDeflateCodec c = new AdobeDeflateCodec(); 
    1797       return c.decompress(input); 
     1785      return new AdobeDeflateCodec().decompress(input); 
    17981786    } 
    17991787    else if (compression == THUNDERSCAN) { 
    18001788      throw new FormatException("Sorry, " + 
    18011789        "Thunderscan compression mode is not supported"); 
     1790    } 
     1791    else if (compression == NIKON) { 
     1792      //return new NikonCodec().decompress(input); 
     1793      throw new FormatException("Sorry, Nikon compression mode is not " + 
     1794        "supported; we hope to support it in the future"); 
     1795    } 
     1796    else if (compression == LURAWAVE) { 
     1797      return new LuraWaveCodec().decompress(input); 
    18021798    } 
    18031799    else { 
  • trunk/loci/formats/codec/BaseCodec.java

    r2450 r2711  
    4040public abstract class BaseCodec implements Codec { 
    4141 
    42   /** 
    43    * Compresses a block of data. 
    44    * 
    45    * @param data the data to be compressed 
    46    * @param x length of the x dimension of the image data, if appropriate 
    47    * @param y length of the y dimension of the image data, if appropriate 
    48    * @param dims the dimensions of the image data, if appropriate 
    49    * @param options options to be used during compression, if appropriate 
    50    * @return The compressed data 
    51    * @throws FormatException If input is not an LZW-compressed data block. 
    52    */ 
    53   public abstract byte[] compress(byte[] data, int x, int y, 
    54       int[] dims, Object options) throws FormatException; 
    55  
    56   /** 
    57    * 2D data block encoding default implementation. 
    58    * This method simply concatenates data[0] + data[1] + ... + data[i] into 
    59    * a 1D block of data, then calls the 1D version of compress. 
    60    * 
    61    * @param data the data to be compressed 
    62    * @param x length of the x dimension of the image data, if appropriate 
    63    * @param y length of the y dimension of the image data, if appropriate 
    64    * @param dims the dimensions of the image data, if appropriate 
    65    * @param options options to be used during compression, if appropriate 
    66    * @return The compressed data 
    67    * @throws FormatException If input is not an LZW-compressed data block. 
    68    */ 
    69   public byte[] compress(byte[][] data, int x, int y, int[] dims, 
    70       Object options) throws FormatException 
    71   { 
    72     int len = 0; 
    73     for(int i = 0; i < data.length; i++) { 
    74       len += data[i].length; 
    75     } 
    76     byte[] toCompress = new byte[len]; 
    77     int curPos = 0; 
    78     for(int i = 0; i < data.length; i++) { 
    79       System.arraycopy(data[i], 0, toCompress, curPos, data[i].length); 
    80       curPos += data[i].length; 
    81     } 
    82     return compress(toCompress, x, y, dims, options); 
    83   } 
    84  
    85   /** 
    86    * Decompresses a block of data. 
    87    * 
    88    * @param data the data to be compressed 
    89    * @return The compressed data 
    90    * @throws FormatException If input is not an LZW-compressed data block. 
    91    */ 
    92   public abstract byte[] decompress(byte[] data) throws FormatException; 
    93  
    94   /** 
    95    * 2D data block decoding default implementation. 
    96    * This method simply concatenates data[0] + data[1] + ... + data[i] into 
    97    * a 1D block of data, then calls the 1D version of decompress. 
    98    * 
    99    * @param data the data to be decompressed 
    100    * @return The decompressed data 
    101    * @throws FormatException If input is not an compressed data block of the 
    102    *         appropriate type. 
    103    */ 
    104   public byte[] decompress(byte[][] data) throws FormatException { 
    105     int len = 0; 
    106     for(int i = 0; i < data.length; i++) { 
    107       len += data[i].length; 
    108     } 
    109     byte[] toDecompress = new byte[len]; 
    110     int curPos = 0; 
    111     for(int i = 0; i < data.length; i++) { 
    112       System.arraycopy(data[i], 0, toDecompress, curPos, data[i].length); 
    113       curPos += data[i].length; 
    114     } 
    115     return decompress(toDecompress); 
    116   } 
     42  // -- BaseCodec API methods -- 
    11743 
    11844  /** 
     
    12349   * 
    12450   * @throws FormatException Can only occur if there is a bug in the 
    125    *                         compress method. 
     51   *   compress method. 
    12652   */ 
    12753  public void test() throws FormatException { 
     
    13763    byte[] decompressed = decompress(compressed); 
    13864    System.out.print("Comparing data... "); 
    139     if(testdata.length != decompressed.length) { 
     65    if (testdata.length != decompressed.length) { 
    14066      System.out.println("Test data differs in length from uncompressed data"); 
    14167      System.out.println("Exiting..."); 
     
    14470    else { 
    14571      boolean equalsFlag = true; 
    146       for(int i = 0; i < testdata.length; i++) { 
    147         if(testdata[i] != decompressed[i]) { 
     72      for (int i = 0; i < testdata.length; i++) { 
     73        if (testdata[i] != decompressed[i]) { 
    14874          System.out.println("Test data and uncompressed data differs at byte" + 
    14975                             i); 
     
    15177        } 
    15278      } 
    153       if(!equalsFlag) { 
     79      if (!equalsFlag) { 
    15480        System.out.println("Comparison failed. \nExiting..."); 
    15581        System.exit(-1); 
     
    15985    System.out.println("Generating 2D byte array test"); 
    16086    byte[][] twoDtest = new byte[100][500]; 
    161     for(int i = 0; i < 100; i++) { 
     87    for (int i = 0; i < 100; i++) { 
    16288      System.arraycopy(testdata, 500*i, twoDtest[i], 0, 500); 
    16389    } 
    16490    byte[] twoDcompressed = compress(twoDtest, 0, 0, null, null); 
    16591    System.out.print("Comparing compressed data... "); 
    166     if(twoDcompressed.length != compressed.length) { 
     92    if (twoDcompressed.length != compressed.length) { 
    16793      System.out.println("1D and 2D compressed data not same length"); 
    16894      System.out.println("Exiting..."); 
     
    17096    } 
    17197    boolean equalsFlag = true; 
    172     for(int i = 0; i < twoDcompressed.length; i++) { 
    173       if(twoDcompressed[i] != compressed[i]) { 
     98    for (int i = 0; i < twoDcompressed.length; i++) { 
     99      if (twoDcompressed[i] != compressed[i]) { 
    174100        System.out.println("1D data and 2D compressed data differs at byte" + 
    175101                           i); 
    176102        equalsFlag = false; 
    177103      } 
    178       if(!equalsFlag) { 
     104      if (!equalsFlag) { 
    179105        System.out.println("Comparison failed. \nExiting..."); 
    180106        System.exit(-1); 
     
    184110    System.out.println("Test complete."); 
    185111  } 
     112 
     113  // -- Codec API methods -- 
     114 
     115  /** 
     116   * 2D data block encoding default implementation. 
     117   * This method simply concatenates data[0] + data[1] + ... + data[i] into 
     118   * a 1D block of data, then calls the 1D version of compress. 
     119   * 
     120   * @param data The data to be compressed. 
     121   * @param x Length of the x dimension of the image data, if appropriate. 
     122   * @param y Length of the y dimension of the image data, if appropriate. 
     123   * @param dims The dimensions of the image data, if appropriate. 
     124   * @param options Options to be used during compression, if appropriate. 
     125   * @return The compressed data. 
     126   * @throws FormatException If input is not a compressed data block of the 
     127   *   appropriate type. 
     128   */ 
     129  public byte[] compress(byte[][] data, int x, int y, 
     130    int[] dims, Object options) throws FormatException 
     131  { 
     132    int len = 0; 
     133    for (int i = 0; i < data.length; i++) { 
     134      len += data[i].length; 
     135    } 
     136    byte[] toCompress = new byte[len]; 
     137    int curPos = 0; 
     138    for (int i = 0; i < data.length; i++) { 
     139      System.arraycopy(data[i], 0, toCompress, curPos, data[i].length); 
     140      curPos += data[i].length; 
     141    } 
     142    return compress(toCompress, x, y, dims, options); 
     143  } 
     144 
     145  /** 
     146   * 2D data block decoding default implementation. 
     147   * This method simply concatenates data[0] + data[1] + ... + data[i] into 
     148   * a 1D block of data, then calls the 1D version of decompress. 
     149   * 
     150   * @param data The data to be decompressed. 
     151   * @return The decompressed data. 
     152   * @throws FormatException If input is not a compressed data block of the 
     153   *   appropriate type. 
     154   */ 
     155  public byte[] decompress(byte[][] data) throws FormatException { 
     156    int len = 0; 
     157    for (int i = 0; i < data.length; i++) { 
     158      len += data[i].length; 
     159    } 
     160    byte[] toDecompress = new byte[len]; 
     161    int curPos = 0; 
     162    for (int i = 0; i < data.length; i++) { 
     163      System.arraycopy(data[i], 0, toDecompress, curPos, data[i].length); 
     164      curPos += data[i].length; 
     165    } 
     166    return decompress(toDecompress); 
     167  } 
     168 
    186169} 
  • trunk/loci/formats/codec/Codec.java

    r2450 r2711  
    4949   * Compresses a block of data. 
    5050   * 
    51    * @param data the data to be compressed 
    52    * @param x length of the x dimension of the image data, if appropriate 
    53    * @param y length of the y dimension of the image data, if appropriate 
    54    * @param dims the dimensions of the image data, if appropriate 
    55    * @param options options to be used during compression, if appropriate 
    56    * @return The compressed data 
    57    * @throws FormatException If input is not an LZW-compressed data block. 
     51   * @param data The data to be compressed. 
     52   * @param x Length of the x dimension of the image data, if appropriate. 
     53   * @param y Length of the y dimension of the image data, if appropriate. 
     54   * @param dims The dimensions of the image data, if appropriate. 
     55   * @param options Options to be used during compression, if appropriate. 
     56   * @return The compressed data. 
     57   * @throws FormatException If input is not a compressed data block of the 
     58   *   appropriate type. 
    5859   */ 
    5960  byte[] compress(byte[] data, int x, int y, 
     
    6364   * Compresses a block of data. 
    6465   * 
    65    * @param data the data to be compressed 
    66    * @param x length of the x dimension of the image data, if appropriate 
    67    * @param y length of the y dimension of the image data, if appropriate 
    68    * @param dims the dimensions of the image data, if appropriate 
    69    * @param options options to be used during compression, if appropriate 
    70    * @return The compressed data 
    71    * @throws FormatException If input is not an LZW-compressed data block. 
     66   * @param data The data to be compressed. 
     67   * @param x Length of the x dimension of the image data, if appropriate. 
     68   * @param y Length of the y dimension of the image data, if appropriate. 
     69   * @param dims The dimensions of the image data, if appropriate. 
     70   * @param options Options to be used during compression, if appropriate. 
     71   * @return The compressed data. 
     72   * @throws FormatException If input is not a compressed data block of the 
     73   *   appropriate type. 
    7274   */ 
    7375  byte[] compress(byte[][] data, int x, int y, 
     
    7779   * Decompresses a block of data. 
    7880   * 
    79    * @param data the data to be decompressed 
    80    * @return The decompressed data 
    81    * @throws FormatException if data is not valid compressed data for this 
    82    *                         decompressor 
     81   * @param data the data to be decompressed. 
     82   * @return The decompressed data. 
     83   * @throws FormatException If data is not valid compressed data for this 
     84   *   decompressor. 
    8385   */ 
    8486  byte[] decompress(byte[] data) throws FormatException; 
     
    8789   * Decompresses a block of data. 
    8890   * 
    89    * @param data the data to be decompressed 
    90    * @return The decompressed data 
    91    * @throws FormatException if data is not valid compressed data for this 
    92    *                         decompressor 
     91   * @param data The data to be decompressed. 
     92   * @return The decompressed data. 
     93   * @throws FormatException If data is not valid compressed data for this 
     94   *   decompressor. 
    9395   */ 
    9496  byte[] decompress(byte[][] data) throws FormatException; 
  • trunk/loci/formats/readers.txt

    r2625 r2711  
    7373loci.formats.in.GelReader          # gel 
    7474loci.formats.in.ImarisTiffReader   # ims 
     75loci.formats.in.FlexReader         # flex 
    7576 
    7677# TIFF-based readers with slow isThisType 
Note: See TracChangeset for help on using the changeset viewer.