OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [javax/] [imageio/] [plugins/] [jpeg/] [JPEGImageReadParam.java] - Blame information for rev 772

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 772 jeremybenn
/* JPEGImageReadParam.java --
2
 Copyright (C)  2006  Free Software Foundation, Inc.
3
 
4
 This file is part of GNU Classpath.
5
 
6
 GNU Classpath is free software; you can redistribute it and/or modify
7
 it under the terms of the GNU General Public License as published by
8
 the Free Software Foundation; either version 2, or (at your option)
9
 any later version.
10
 
11
 GNU Classpath is distributed in the hope that it will be useful, but
12
 WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 General Public License for more details.
15
 
16
 You should have received a copy of the GNU General Public License
17
 along with GNU Classpath; see the file COPYING.  If not, write to the
18
 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
 02110-1301 USA.
20
 
21
 Linking this library statically or dynamically with other modules is
22
 making a combined work based on this library.  Thus, the terms and
23
 conditions of the GNU General Public License cover the whole
24
 combination.
25
 
26
 As a special exception, the copyright holders of this library give you
27
 permission to link this library with independent modules to produce an
28
 executable, regardless of the license terms of these independent
29
 modules, and to copy and distribute the resulting executable under
30
 terms of your choice, provided that you also meet, for each linked
31
 independent module, the terms and conditions of the license of that
32
 module.  An independent module is a module which is not derived from
33
 or based on this library.  If you modify this library, you may extend
34
 this exception to your version of the library, but you are not
35
 obligated to do so.  If you do not wish to do so, delete this
36
 exception statement from your version. */
37
 
38
 
39
package javax.imageio.plugins.jpeg;
40
 
41
import javax.imageio.ImageReadParam;
42
 
43
/**
44
 * The JPEGImageReadParam class is only used to set JPEG decoding
45
 * tables for streams that do not provide their own tables.  If a
46
 * stream does not provide tables and a custom JPEGImageReadParam is
47
 * not provided, then the standard JPEG tables are used from the
48
 * JPEGQTable and JPEGHuffmanTable classes.  If a stream does provide
49
 * decoding tables then JPEGImageReadParam will be ignored.
50
 * JPEGImageReadParam cannot be used to retrieve the tables from a
51
 * stream.  Instead, use IIOMetadata for this purpose.
52
 *
53
 * A JPEGImageReadParam instance is retrieved from the built-in JPEG
54
 * ImageReader using the getDefaultImageReadParam method.
55
 */
56
public class JPEGImageReadParam
57
  extends ImageReadParam
58
{
59
  private JPEGQTable[] qTables;
60
  private JPEGHuffmanTable[] DCHuffmanTables;
61
  private JPEGHuffmanTable[] ACHuffmanTables;
62
 
63
  /**
64
   * Construct a JPEGImageReadParam.
65
   */
66
  public JPEGImageReadParam()
67
  {
68
    super();
69
  }
70
 
71
  /**
72
   * Check if the decoding tables are set.
73
   *
74
   * @return true if the decoding tables are set, false otherwise
75
   */
76
  public boolean areTablesSet()
77
  {
78
    // If qTables is not null then all tables are set.
79
    return (qTables != null);
80
  }
81
 
82
  /**
83
   * Set the quantization and Huffman tables that will be used to
84
   * decode the stream.  Copies are created of the array arguments.
85
   * The number of Huffman tables must be the same in both Huffman
86
   * table arrays.  No argument may be null and no array may be longer
87
   * than four elements.
88
   *
89
   * @param qTables JPEG quantization tables
90
   * @param DCHuffmanTables JPEG DC Huffman tables
91
   * @param ACHuffmanTables JPEG AC Huffman tables
92
   *
93
   * @throws IllegalArgumentException if any argument is null, if any
94
   * of the arrays are longer than four elements, or if the Huffman
95
   * table arrays do not have the same number of elements
96
   */
97
  public void setDecodeTables(JPEGQTable[] qTables,
98
                              JPEGHuffmanTable[] DCHuffmanTables,
99
                              JPEGHuffmanTable[] ACHuffmanTables)
100
  {
101
    if (qTables == null || DCHuffmanTables == null || ACHuffmanTables == null)
102
      throw new IllegalArgumentException("null argument");
103
 
104
    if (qTables.length > 4 || DCHuffmanTables.length > 4
105
        || ACHuffmanTables.length > 4)
106
      throw new IllegalArgumentException("argument has too many elements");
107
 
108
    if (DCHuffmanTables.length != ACHuffmanTables.length)
109
      throw new IllegalArgumentException("Huffman table arrays differ in length");
110
 
111
    // Do a shallow copy.  JPEGQTable's data is not directly
112
    // modifyable since JPEGQTable.getTable returns a copy.  Therefore
113
    // it is safe to have multiple references to a single JPEGQTable.
114
    // Likewise for JPEGHuffmanTable.
115
    this.qTables = (JPEGQTable[]) qTables.clone();
116
    this.DCHuffmanTables = (JPEGHuffmanTable[]) DCHuffmanTables.clone();
117
    this.ACHuffmanTables = (JPEGHuffmanTable[]) ACHuffmanTables.clone();
118
  }
119
 
120
  /**
121
   * Clear the quantization and Huffman decoding tables.
122
   */
123
  public void unsetDecodeTables()
124
  {
125
    qTables = null;
126
    DCHuffmanTables = null;
127
    ACHuffmanTables = null;
128
  }
129
 
130
  /**
131
   * Retrieve the quantization tables.
132
   *
133
   * @returns an array of JPEG quantization tables
134
   */
135
  public JPEGQTable[] getQTables()
136
  {
137
    return qTables == null ? qTables : (JPEGQTable[]) qTables.clone();
138
  }
139
 
140
  /**
141
   * Retrieve the DC Huffman tables.
142
   *
143
   * @return an array of JPEG DC Huffman tables
144
   */
145
  public JPEGHuffmanTable[] getDCHuffmanTables()
146
  {
147
    return DCHuffmanTables == null ? DCHuffmanTables
148
      : (JPEGHuffmanTable[]) DCHuffmanTables.clone();
149
  }
150
 
151
  /**
152
   * Retrieve the AC Huffman tables.
153
   *
154
   * @return an array of JPEG AC Huffman tables
155
   */
156
  public JPEGHuffmanTable[] getACHuffmanTables()
157
  {
158
    return ACHuffmanTables == null ? ACHuffmanTables
159
      : (JPEGHuffmanTable[]) ACHuffmanTables.clone();
160
  }
161
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.