Changeset 2450


Ignore:
Timestamp:
03/14/07 14:54:40 (13 years ago)
Author:
curtis
Message:

Move compression/decompression logic into new loci.formats.codec package.

Location:
trunk/loci/formats
Files:
1 added
6 edited
13 moved

Legend:

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

    r2418 r2450  
    3232import java.nio.*; 
    3333import java.util.*; 
     34import loci.formats.codec.*; 
    3435 
    3536/** 
     
    18021803    } 
    18031804    else if (compression == LZW) { 
    1804       LZWCompressor c = new LZWCompressor(); 
     1805      LZWCodec c = new LZWCodec(); 
    18051806      return c.decompress(input); 
    18061807      // return Compression.lzwUncompress(input); 
     
    18181819    } 
    18191820    else if (compression == PACK_BITS) { 
    1820       PackbitsCompressor c = new PackbitsCompressor(); 
     1821      PackbitsCodec c = new PackbitsCodec(); 
    18211822      return c.decompress(input); 
    18221823 
     
    18251826    else if (compression == PROPRIETARY_DEFLATE || compression == DEFLATE) { 
    18261827      //return Compression.deflateUncompress(input); 
    1827       AdobeDeflateCompressor c = new AdobeDeflateCompressor(); 
     1828      AdobeDeflateCodec c = new AdobeDeflateCodec(); 
    18281829      return c.decompress(input); 
    18291830    } 
     
    24522453    } 
    24532454    else if (compression == LZW) { 
    2454       LZWCompressor c = new LZWCompressor(); 
     2455      LZWCodec c = new LZWCodec(); 
    24552456      return c.compress(input, 0, 0, null, null); 
    24562457      // return Compression.lzwCompress(input); 
  • trunk/loci/formats/codec/AdobeDeflateCodec.java

    r2178 r2450  
    11// 
    2 // AdobeDeflateCompressor.java 
     2// AdobeDeflateCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727import java.io.PipedInputStream; 
    2828import java.util.zip.Inflater; 
    2929import java.util.zip.InflaterInputStream; 
     30import loci.formats.FormatException; 
    3031 
    3132/** 
    3233 * This class implements Adobe Deflate decompression. Compression is not yet 
    3334 * implemented. 
     35 * 
     36 * @author Melissa Linkert linkert at wisc.edu 
    3437 */ 
    35 public class AdobeDeflateCompressor 
    36     extends BaseCompressor implements Compressor 
    37 { 
     38public class AdobeDeflateCodec extends BaseCodec implements Codec { 
    3839 
    3940  /** 
     
    8384    } 
    8485  } 
     86 
    8587} 
  • trunk/loci/formats/codec/Base64Codec.java

    r2211 r2450  
    11// 
    2 // Base64Encoder.java 
     2// Base64Codec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
    28  * Implements encoding (compress) and decoding (decompress) methods for 
    29  * Base64. 
     30 * Implements encoding (compress) and decoding (decompress) methods 
     31 * for Base64. 
     32 * 
     33 * @author Melissa Linkert linkert at wisc.edu 
    3034 */ 
    31 public class Base64Encoder extends BaseCompressor implements Compressor { 
     35public class Base64Codec extends BaseCodec implements Codec { 
    3236 
    3337  // Base64 alphabet and codes 
     
    236240 
    237241  public static void main(String[] args) throws FormatException { 
    238     Base64Encoder c = new Base64Encoder(); 
     242    Base64Codec c = new Base64Codec(); 
    239243    c.test(); 
    240244  } 
  • trunk/loci/formats/codec/BaseCodec.java

    r2178 r2450  
    11// 
    2 // BaseCompressor.java 
     2// BaseCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727import java.util.*; 
     28import loci.formats.FormatException; 
    2829 
    2930/** 
    30  * BaseCompressor contains default implementation and testing for classes 
    31  * implementing the Compressor interface, and acts as a base class for any 
     31 * BaseCodec contains default implementation and testing for classes 
     32 * implementing the Codec interface, and acts as a base class for any 
    3233 * of the compression classes. 
    3334 * Base 1D compression and decompression methods are not implemented here, and 
    3435 * are left as abstract. 2D methods do simple concatenation and call to the 1D 
    3536 * methods 
     37 * 
     38 * @author Eric Kjellman egkjellman at wisc.edu 
    3639 */ 
    37 public abstract class BaseCompressor implements Compressor { 
     40public abstract class BaseCodec implements Codec { 
    3841 
    3942  /** 
  • trunk/loci/formats/codec/BitBuffer.java

    r2178 r2450  
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727import java.util.Random; // used in main method test 
  • trunk/loci/formats/codec/BitWriter.java

    r2178 r2450  
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727import java.util.*; 
  • trunk/loci/formats/codec/ByteVector.java

    r2178 r2450  
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727/** 
  • trunk/loci/formats/codec/Codec.java

    r2178 r2450  
    11// 
    2 // Compressor.java 
     2// Codec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
    28  * This class is an interface for any kind of compression. 
    29  * data is presented to the compressor in a 1D or 2D byte array, 
     30 * This class is an interface for any kind of compression or decompression. 
     31 * Data is presented to the compressor in a 1D or 2D byte array, 
    3032 * with (optionally, depending on the compressor) pixel dimensions and 
    3133 * an Object containing any other options the compressor may need. 
     
    3638 * compressor to throw a NullPointerException. 
    3739 * 
    38  * Classes implementing the Compressor interface are expected to either 
     40 * Classes implementing the Codec interface are expected to either 
    3941 * implement both compression methods or neither. (The same is expected for 
    4042 * decompression). 
     43 * 
     44 * @author Eric Kjellman egkjellman at wisc.edu 
    4145 */ 
    42 public interface Compressor { 
     46public interface Codec { 
    4347 
    4448  /** 
  • trunk/loci/formats/codec/JPEGCodec.java

    r2320 r2450  
    11// 
    2 // JPEGCompressor.java 
     2// JPEGCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727import java.awt.image.BufferedImage; 
    2828import java.io.*; 
    2929import javax.imageio.ImageIO; 
     30import loci.formats.FormatException; 
     31import loci.formats.ImageTools; 
    3032 
    3133/** 
     
    3335 * implemented. 
    3436 */ 
    35 public class JPEGCompressor extends BaseCompressor implements Compressor { 
     37public class JPEGCodec extends BaseCodec implements Codec { 
    3638 
    3739  /** 
     
    6668      b = ImageIO.read(new ByteArrayInputStream(input)); 
    6769    } catch (IOException e) { 
    68       System.err.println("An IO Error occurred decompressing image." + 
     70      System.err.println("An I/O Error occurred decompressing image." + 
    6971        " Stack dump follows:"); 
    7072      e.printStackTrace(); 
  • trunk/loci/formats/codec/LZOCodec.java

    r2178 r2450  
    11// 
    2 // LZOCompressor.java 
     2// LZOCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
    2830 * This class implements LZO decompression. Compression is not yet 
    2931 * implemented. 
     32 * 
     33 * @author Melissa Linkert linkert at wisc.edu 
    3034 */ 
    31 public class LZOCompressor extends BaseCompressor implements Compressor { 
     35public class LZOCodec extends BaseCodec implements Codec { 
    3236 
    3337  // LZO compression codes 
     
    6367   */ 
    6468  public byte[] decompress(byte[] src) throws FormatException { 
    65 //    public static void lzoUncompress(byte[] src, int size, byte[] dst) 
    66 //    throws FormatException 
    6769    int ip = 0; 
    6870    int op = 0; 
  • trunk/loci/formats/codec/LZWCodec.java

    r2178 r2450  
    11// 
    2 // LZWCompressor.java 
     2// LZWCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
     
    3032 * http://partners.adobe.com/asn/developer/pdfs/tn/TIFF6.pdf (page 61). 
    3133 * 
     34 * @author Eric Kjellman egkjellman at wisc.edu 
     35 * @author Curtis Rueden ctrueden at wisc.edu 
     36 * @author Wayne Rasband wsr at nih.gov 
    3237 */ 
    33 public class LZWCompressor extends BaseCompressor implements Compressor { 
     38public class LZWCodec extends BaseCodec implements Codec { 
    3439 
    3540  // LZW compression codes 
     
    5156    Object options) throws FormatException 
    5257  { 
    53  
    5458    if (input == null || input.length == 0) return input; 
    5559 
     
    102106   */ 
    103107  public byte[] decompress(byte[] input) throws FormatException { 
    104     // Written by Eric Kjellman egkjellman at wisc.edu 
    105     // Modified by Wayne Rasband wsr at nih.gov 
    106108    if (input == null || input.length == 0) return input; 
    107109 
     
    172174   *                         compress method. 
    173175   */ 
    174  
    175176  public static void main(String[] args) throws FormatException { 
    176     LZWCompressor c = new LZWCompressor(); 
     177    LZWCodec c = new LZWCodec(); 
    177178    c.test(); 
    178179  } 
  • trunk/loci/formats/codec/LZWTreeNode.java

    r2178 r2450  
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
    2626 
    2727/** 
  • trunk/loci/formats/codec/NikonCodec.java

    r2178 r2450  
    11// 
    2 // NikonCompressor.java 
     2// NikonCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
    2830 * This class implements Nikon decompression. Compression is not yet 
    2931 * implemented. 
     32 * 
     33 * @author Melissa Linkert linkert at wisc.edu 
    3034 */ 
    31 public class NikonCompressor extends BaseCompressor implements Compressor { 
     35public class NikonCodec extends BaseCodec implements Codec { 
    3236 
    3337  /** Huffman tree for the Nikon decoder. */ 
  • trunk/loci/formats/codec/PackbitsCodec.java

    r2178 r2450  
    11// 
    2 // PackbitsCompressor.java 
     2// PackbitsCodec.java 
    33// 
    44 
     
    2323*/ 
    2424 
    25 package loci.formats; 
     25package loci.formats.codec; 
     26 
     27import loci.formats.FormatException; 
    2628 
    2729/** 
    2830 * This class implements packbits decompression. Compression is not yet 
    2931 * implemented. 
     32 * 
     33 * @author Melissa Linkert linkert at wisc.edu 
    3034 */ 
    31 public class PackbitsCompressor 
    32     extends BaseCompressor implements Compressor 
    33 { 
     35public class PackbitsCodec extends BaseCodec implements Codec { 
    3436 
    3537  /** 
     
    6163   */ 
    6264  public byte[] decompress(byte[] input) throws FormatException { 
    63     // Written by Melissa Linkert linkert at wisc.edu 
    6465    ByteVector output = new ByteVector(input.length); 
    6566    int pt = 0; 
  • trunk/loci/formats/in/ICSReader.java

    r2430 r2450  
    3030import java.util.zip.*; 
    3131import loci.formats.*; 
     32import loci.formats.codec.ByteVector; 
    3233 
    3334/** 
  • trunk/loci/formats/in/OMEXMLReader.java

    r2430 r2450  
    3030import java.util.zip.*; 
    3131import loci.formats.*; 
     32import loci.formats.codec.Base64Codec; 
    3233import loci.formats.ome.OMEXMLMetadataStore; 
    3334import org.openmicroscopy.xml.OMENode; 
     
    178179 
    179180    //byte[] pixels = Compression.base64Decode(pix); 
    180     Base64Encoder e = new Base64Encoder(); 
     181    Base64Codec e = new Base64Codec(); 
    181182    byte[] pixels = e.base64Decode(pix); 
    182183    pix = null; 
  • trunk/loci/formats/in/OpenlabReader.java

    r2430 r2450  
    3030import java.util.Vector; 
    3131import loci.formats.*; 
     32import loci.formats.codec.LZOCodec; 
    3233 
    3334/** 
     
    304305      in.read(c); 
    305306 
    306 //      Compression.lzoUncompress(c, size, b); 
    307       LZOCompressor lzoc = new LZOCompressor(); 
     307      LZOCodec lzoc = new LZOCodec(); 
    308308      b = lzoc.decompress(c); 
    309       if(b.length != size) { 
    310         System.err.println("LZOCompressor failed to predict image size"); 
     309      if (b.length != size) { 
     310        System.err.println("LZOCodec failed to predict image size"); 
    311311        System.err.println(size + " expected, got " + b.length + 
    312                            ". The image displayed may not be correct."); 
     312          ". The image displayed may not be correct."); 
    313313      } 
    314314 
  • trunk/loci/formats/in/PictReader.java

    r2430 r2450  
    3030import java.util.*; 
    3131import loci.formats.*; 
     32import loci.formats.codec.PackbitsCodec; 
    3233 
    3334/** 
     
    553554        } 
    554555 
    555         PackbitsCompressor c = new PackbitsCompressor(); 
     556        PackbitsCodec c = new PackbitsCodec(); 
    556557        uBuf = c.decompress(buf); 
    557558        //uBuf = Compression.packBitsUncompress(buf); 
     
    775776        } 
    776777        else { 
    777           PackbitsCompressor c = new PackbitsCompressor(); 
     778          PackbitsCodec c = new PackbitsCodec(); 
    778779          uBuf = c.decompress(buf); 
    779780          //uBuf = Compression.packBitsUncompress(buf); 
  • trunk/loci/formats/in/QTReader.java

    r2430 r2450  
    3030import javax.imageio.ImageIO; 
    3131import loci.formats.*; 
     32import loci.formats.codec.ByteVector; 
    3233 
    3334/** 
Note: See TracChangeset for help on using the changeset viewer.