< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  57 import org.w3c.dom.Node;
  58 
  59 /**
  60  * Base class for all possible forms of JPEG compression in TIFF.
  61  */
  62 public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor {
  63 
  64     // Stream metadata format.
  65     protected static final String STREAM_METADATA_NAME =
  66         "javax_imageio_jpeg_stream_1.0";
  67 
  68     // Image metadata format.
  69     protected static final String IMAGE_METADATA_NAME =
  70         "javax_imageio_jpeg_image_1.0";
  71 
  72     // ImageWriteParam passed in.
  73     private ImageWriteParam param = null;
  74 
  75     /**
  76      * ImageWriteParam for JPEG writer.
  77      * May be initialized by {@link #initJPEGWriter()}.
  78      */
  79     protected JPEGImageWriteParam JPEGParam = null;
  80 
  81     /**
  82      * The JPEG writer.
  83      * May be initialized by {@link #initJPEGWriter()}.
  84      */
  85     protected ImageWriter JPEGWriter = null;
  86 
  87     /**
  88      * Whether to write abbreviated JPEG streams (default == false).
  89      * A subclass which sets this to {@code true} should also
  90      * initialized {@link #JPEGStreamMetadata}.
  91      */
  92     protected boolean writeAbbreviatedStream = false;
  93 
  94     /**
  95      * Stream metadata equivalent to a tables-only stream such as in
  96      * the {@code JPEGTables}. Default value is {@code null}.
  97      * This should be set by any subclass which sets
  98      * {@link writeAbbreviatedStream} to {@code true}.
  99      */
 100     protected IIOMetadata JPEGStreamMetadata = null;
 101 
 102     // A pruned image metadata object containing only essential nodes.
 103     private IIOMetadata JPEGImageMetadata = null;
 104 
 105     // Array-based output stream.
 106     private IIOByteArrayOutputStream baos;
 107 
 108     /**
 109      * Removes nonessential nodes from a JPEG native image metadata tree.
 110      * All nodes derived from JPEG marker segments other than DHT, DQT,
 111      * SOF, SOS segments are removed unless {@code pruneTables} is
 112      * {@code true} in which case the nodes derived from the DHT and
 113      * DQT marker segments are also removed.
 114      *
 115      * @param tree A <tt>javax_imageio_jpeg_image_1.0</tt> tree.
 116      * @param pruneTables Whether to prune Huffman and quantization tables.
 117      * @throws NullPointerException if {@code tree} is
 118      * {@code null}.


   1 /*
   2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  57 import org.w3c.dom.Node;
  58 
  59 /**
  60  * Base class for all possible forms of JPEG compression in TIFF.
  61  */
  62 public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor {
  63 
  64     // Stream metadata format.
  65     protected static final String STREAM_METADATA_NAME =
  66         "javax_imageio_jpeg_stream_1.0";
  67 
  68     // Image metadata format.
  69     protected static final String IMAGE_METADATA_NAME =
  70         "javax_imageio_jpeg_image_1.0";
  71 
  72     // ImageWriteParam passed in.
  73     private ImageWriteParam param = null;
  74 
  75     /**
  76      * ImageWriteParam for JPEG writer.
  77      * May be initialized by {@link #initJPEGWriter}.
  78      */
  79     protected JPEGImageWriteParam JPEGParam = null;
  80 
  81     /**
  82      * The JPEG writer.
  83      * May be initialized by {@link #initJPEGWriter}.
  84      */
  85     protected ImageWriter JPEGWriter = null;
  86 
  87     /**
  88      * Whether to write abbreviated JPEG streams (default == false).
  89      * A subclass which sets this to {@code true} should also
  90      * initialized {@link #JPEGStreamMetadata}.
  91      */
  92     protected boolean writeAbbreviatedStream = false;
  93 
  94     /**
  95      * Stream metadata equivalent to a tables-only stream such as in
  96      * the {@code JPEGTables}. Default value is {@code null}.
  97      * This should be set by any subclass which sets
  98      * {@link #writeAbbreviatedStream} to {@code true}.
  99      */
 100     protected IIOMetadata JPEGStreamMetadata = null;
 101 
 102     // A pruned image metadata object containing only essential nodes.
 103     private IIOMetadata JPEGImageMetadata = null;
 104 
 105     // Array-based output stream.
 106     private IIOByteArrayOutputStream baos;
 107 
 108     /**
 109      * Removes nonessential nodes from a JPEG native image metadata tree.
 110      * All nodes derived from JPEG marker segments other than DHT, DQT,
 111      * SOF, SOS segments are removed unless {@code pruneTables} is
 112      * {@code true} in which case the nodes derived from the DHT and
 113      * DQT marker segments are also removed.
 114      *
 115      * @param tree A <tt>javax_imageio_jpeg_image_1.0</tt> tree.
 116      * @param pruneTables Whether to prune Huffman and quantization tables.
 117      * @throws NullPointerException if {@code tree} is
 118      * {@code null}.


< prev index next >