gnu.javax.imageio.jpeg

Class JPEGComponent


public class JPEGComponent
extends Object

This class holds the methods to decode and write a component information to a raster.

Field Summary

HuffmanTable
ACTable
HuffmanTable
DCTable
byte
component_id
byte
factorH
byte
factorV
int
height
int
maxH
int
maxV
double
previousDC
byte
quant_id
int[]
quantizationTable
int
width

Constructor Summary

JPEGComponent(byte id, byte factorHorizontal, byte factorVertical, byte quantizationID)
Initializes the component

Method Summary

double[]
decode_ac_coefficients(JPEGImageInputStream JPEGStream)
Generated from text on F-23, F.13 - Huffman decoded of AC coefficients on ISO DIS 10918-1.
double
decode_dc_coefficient(JPEGImageInputStream JPEGStream)
Generated from text on F-22, F.2.2.1 - Huffman decoding of DC coefficients on ISO DIS 10918-1.
void
idctData(DCT myDCT)
Run the Inverse DCT method on all of the block data
void
padMCU(int index, int length)
If a restart marker is found with too little of an MCU count (i.e. our Restart Interval is 63 and we have 61 we copy the last MCU until it's full)
void
quantitizeData()
Run the Quantization backward method on all of the block data.
void
readComponentMCU(JPEGImageInputStream stream)
Read in a partial MCU for this component
void
resetInterval()
Reset the interval by setting the previous DC value
void
scaleByFactors()
This scales up the component size based on the factor size.
void
setACTable(JPEGHuffmanTable table)
void
setDCTable(JPEGHuffmanTable table)
void
setQuantizationTable(int[] quanttable)
Set the quantization table for this component.
void
writeBlock(WritableRaster raster, double[][] data, int compIndex, int x, int y)
This write the block of data to the raster throwing out anything that spills over the raster width or height.
void
writeData(WritableRaster raster, int componentIndex)
This writes data to a raster block, so really it's reading not writing but it writes the data to the raster block by factor size in a zig zag fashion.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

ACTable

public HuffmanTable ACTable

DCTable

public HuffmanTable DCTable

component_id

public byte component_id

factorH

public byte factorH

factorV

public byte factorV

height

public int height

maxH

public int maxH

maxV

public int maxV

previousDC

public double previousDC

quant_id

public byte quant_id

quantizationTable

public int[] quantizationTable

width

public int width

Constructor Details

JPEGComponent

public JPEGComponent(byte id,
                     byte factorHorizontal,
                     byte factorVertical,
                     byte quantizationID)
Initializes the component
Parameters:
id -
factorHorizontal -
factorVertical -
quantizationID -

Method Details

decode_ac_coefficients

public double[] decode_ac_coefficients(JPEGImageInputStream JPEGStream)
            throws JPEGException,
                   IOException
Generated from text on F-23, F.13 - Huffman decoded of AC coefficients on ISO DIS 10918-1. Requirements and Guidelines.
Parameters:
JPEGStream - TODO
Returns:
TODO
Throws:
JPEGException - TODO
IOException - TODO

decode_dc_coefficient

public double decode_dc_coefficient(JPEGImageInputStream JPEGStream)
            throws JPEGException,
                   IOException
Generated from text on F-22, F.2.2.1 - Huffman decoding of DC coefficients on ISO DIS 10918-1. Requirements and Guidelines.
Parameters:
JPEGStream - TODO
Returns:
TODO
Throws:
JPEGException - TODO
IOException - TODO

idctData

public void idctData(DCT myDCT)
Run the Inverse DCT method on all of the block data

padMCU

public void padMCU(int index,
                   int length)
If a restart marker is found with too little of an MCU count (i.e. our Restart Interval is 63 and we have 61 we copy the last MCU until it's full)
Parameters:
index -
length -

quantitizeData

public void quantitizeData()
Run the Quantization backward method on all of the block data.

readComponentMCU

public void readComponentMCU(JPEGImageInputStream stream)
            throws JPEGException,
                   IOException
Read in a partial MCU for this component
Parameters:
stream - TODO
Throws:
JPEGException - TODO
IOException - TODO

resetInterval

public void resetInterval()
Reset the interval by setting the previous DC value

scaleByFactors

public void scaleByFactors()
This scales up the component size based on the factor size. This calculates everyting up automatically so it's simply ran at the end of the frame to normalize the size of all of the components.

setACTable

public void setACTable(JPEGHuffmanTable table)

setDCTable

public void setDCTable(JPEGHuffmanTable table)

setQuantizationTable

public void setQuantizationTable(int[] quanttable)
Set the quantization table for this component.
Parameters:
quanttable -

writeBlock

public void writeBlock(WritableRaster raster,
                       double[][] data,
                       int compIndex,
                       int x,
                       int y)
This write the block of data to the raster throwing out anything that spills over the raster width or height.
Parameters:
raster -
data -
compIndex -
x -
y -

writeData

public void writeData(WritableRaster raster,
                      int componentIndex)
This writes data to a raster block, so really it's reading not writing but it writes the data to the raster block by factor size in a zig zag fashion. This has the helper function writeBlock which does the actual writing.
Parameters:
raster -
componentIndex -

JPEGComponent.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.