01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.imageio.plugins.jpeg;
19:
20: import javax.imageio.ImageReadParam;
21:
22: public class JPEGImageReadParam extends ImageReadParam {
23: private JPEGQTable qTables[];
24: private JPEGHuffmanTable dcHuffmanTables[];
25: private JPEGHuffmanTable acHuffmanTables[];
26:
27: public JPEGImageReadParam() {
28: }
29:
30: public boolean areTablesSet() {
31: return qTables != null;
32: }
33:
34: public void setDecodeTables(JPEGQTable[] qTables,
35: JPEGHuffmanTable[] DCHuffmanTables,
36: JPEGHuffmanTable[] ACHuffmanTables) {
37: if (qTables == null || DCHuffmanTables == null
38: || ACHuffmanTables == null) {
39: throw new IllegalArgumentException(
40: "Invalid JPEG table arrays");
41: }
42: if (DCHuffmanTables.length != ACHuffmanTables.length) {
43: throw new IllegalArgumentException(
44: "Invalid JPEG table arrays");
45: }
46: if (qTables.length > 4 || DCHuffmanTables.length > 4) {
47: throw new IllegalArgumentException(
48: "Invalid JPEG table arrays");
49: }
50:
51: // Do the shallow copy, it should be enough
52: this .qTables = qTables.clone();
53: dcHuffmanTables = DCHuffmanTables.clone();
54: acHuffmanTables = ACHuffmanTables.clone();
55: }
56:
57: public void unsetDecodeTables() {
58: qTables = null;
59: dcHuffmanTables = null;
60: acHuffmanTables = null;
61: }
62:
63: public JPEGQTable[] getQTables() {
64: return qTables == null ? null : qTables.clone();
65: }
66:
67: public JPEGHuffmanTable[] getDCHuffmanTables() {
68: return dcHuffmanTables == null ? null : dcHuffmanTables.clone();
69: }
70:
71: public JPEGHuffmanTable[] getACHuffmanTables() {
72: return acHuffmanTables == null ? null : acHuffmanTables.clone();
73: }
74: }
|