src/share/classes/javax/imageio/plugins/jpeg/JPEGImageReadParam.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2001, 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


 115      *
 116      * @exception IllegalArgumentException if any of the arguments
 117      * is <code>null</code>, has more than 4 elements, or if the
 118      * numbers of DC and AC tables differ.
 119      *
 120      * @see #unsetDecodeTables
 121      */
 122     public void setDecodeTables(JPEGQTable[] qTables,
 123                                 JPEGHuffmanTable[] DCHuffmanTables,
 124                                 JPEGHuffmanTable[] ACHuffmanTables) {
 125         if ((qTables == null) ||
 126             (DCHuffmanTables == null) ||
 127             (ACHuffmanTables == null) ||
 128             (qTables.length > 4) ||
 129             (DCHuffmanTables.length > 4) ||
 130             (ACHuffmanTables.length > 4) ||
 131             (DCHuffmanTables.length != ACHuffmanTables.length)) {
 132                 throw new IllegalArgumentException
 133                     ("Invalid JPEG table arrays");
 134         }
 135         this.qTables = (JPEGQTable[])qTables.clone();
 136         this.DCHuffmanTables = (JPEGHuffmanTable[])DCHuffmanTables.clone();
 137         this.ACHuffmanTables = (JPEGHuffmanTable[])ACHuffmanTables.clone();
 138     }
 139 
 140     /**
 141      * Removes any quantization and Huffman tables that are currently
 142      * set.
 143      *
 144      * @see #setDecodeTables
 145      */
 146     public void unsetDecodeTables() {
 147         this.qTables = null;
 148         this.DCHuffmanTables = null;
 149         this.ACHuffmanTables = null;
 150     }
 151 
 152     /**
 153      * Returns a copy of the array of quantization tables set on the
 154      * most recent call to <code>setDecodeTables</code>, or
 155      * <code>null</code> if tables are not currently set.
 156      *
 157      * @return an array of <code>JPEGQTable</code> objects, or
 158      * <code>null</code>.
 159      *
 160      * @see #setDecodeTables
 161      */
 162     public JPEGQTable[] getQTables() {
 163         return (qTables != null) ? (JPEGQTable[])qTables.clone() : null;
 164     }
 165 
 166     /**
 167      * Returns a copy of the array of DC Huffman tables set on the
 168      * most recent call to <code>setDecodeTables</code>, or
 169      * <code>null</code> if tables are not currently set.
 170      *
 171      * @return an array of <code>JPEGHuffmanTable</code> objects, or
 172      * <code>null</code>.
 173      *
 174      * @see #setDecodeTables
 175      */
 176     public JPEGHuffmanTable[] getDCHuffmanTables() {
 177         return (DCHuffmanTables != null)
 178             ? (JPEGHuffmanTable[])DCHuffmanTables.clone()
 179             : null;
 180     }
 181 
 182     /**
 183      * Returns a copy of the array of AC Huffman tables set on the
 184      * most recent call to <code>setDecodeTables</code>, or
 185      * <code>null</code> if tables are not currently set.
 186      *
 187      * @return an array of <code>JPEGHuffmanTable</code> objects, or
 188      * <code>null</code>.
 189      *
 190      * @see #setDecodeTables
 191      */
 192     public JPEGHuffmanTable[] getACHuffmanTables() {
 193         return (ACHuffmanTables != null)
 194             ? (JPEGHuffmanTable[])ACHuffmanTables.clone()
 195             : null;
 196     }
 197 }
   1 /*
   2  * Copyright (c) 2000, 2014, 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


 115      *
 116      * @exception IllegalArgumentException if any of the arguments
 117      * is <code>null</code>, has more than 4 elements, or if the
 118      * numbers of DC and AC tables differ.
 119      *
 120      * @see #unsetDecodeTables
 121      */
 122     public void setDecodeTables(JPEGQTable[] qTables,
 123                                 JPEGHuffmanTable[] DCHuffmanTables,
 124                                 JPEGHuffmanTable[] ACHuffmanTables) {
 125         if ((qTables == null) ||
 126             (DCHuffmanTables == null) ||
 127             (ACHuffmanTables == null) ||
 128             (qTables.length > 4) ||
 129             (DCHuffmanTables.length > 4) ||
 130             (ACHuffmanTables.length > 4) ||
 131             (DCHuffmanTables.length != ACHuffmanTables.length)) {
 132                 throw new IllegalArgumentException
 133                     ("Invalid JPEG table arrays");
 134         }
 135         this.qTables = qTables.clone();
 136         this.DCHuffmanTables = DCHuffmanTables.clone();
 137         this.ACHuffmanTables = ACHuffmanTables.clone();
 138     }
 139 
 140     /**
 141      * Removes any quantization and Huffman tables that are currently
 142      * set.
 143      *
 144      * @see #setDecodeTables
 145      */
 146     public void unsetDecodeTables() {
 147         this.qTables = null;
 148         this.DCHuffmanTables = null;
 149         this.ACHuffmanTables = null;
 150     }
 151 
 152     /**
 153      * Returns a copy of the array of quantization tables set on the
 154      * most recent call to <code>setDecodeTables</code>, or
 155      * <code>null</code> if tables are not currently set.
 156      *
 157      * @return an array of <code>JPEGQTable</code> objects, or
 158      * <code>null</code>.
 159      *
 160      * @see #setDecodeTables
 161      */
 162     public JPEGQTable[] getQTables() {
 163         return (qTables != null) ? qTables.clone() : null;
 164     }
 165 
 166     /**
 167      * Returns a copy of the array of DC Huffman tables set on the
 168      * most recent call to <code>setDecodeTables</code>, or
 169      * <code>null</code> if tables are not currently set.
 170      *
 171      * @return an array of <code>JPEGHuffmanTable</code> objects, or
 172      * <code>null</code>.
 173      *
 174      * @see #setDecodeTables
 175      */
 176     public JPEGHuffmanTable[] getDCHuffmanTables() {
 177         return (DCHuffmanTables != null)
 178             ? DCHuffmanTables.clone()
 179             : null;
 180     }
 181 
 182     /**
 183      * Returns a copy of the array of AC Huffman tables set on the
 184      * most recent call to <code>setDecodeTables</code>, or
 185      * <code>null</code> if tables are not currently set.
 186      *
 187      * @return an array of <code>JPEGHuffmanTable</code> objects, or
 188      * <code>null</code>.
 189      *
 190      * @see #setDecodeTables
 191      */
 192     public JPEGHuffmanTable[] getACHuffmanTables() {
 193         return (ACHuffmanTables != null)
 194             ? ACHuffmanTables.clone()
 195             : null;
 196     }
 197 }