jpview.io
Class JPEGLRGBReader

java.lang.Object
  extended by jpview.io.JPEGLRGBReader
All Implemented Interfaces:
PTMReader

public class JPEGLRGBReader
extends java.lang.Object
implements PTMReader

The JPEGLRGBReader implementation provides a reader for the JPEGLRGB format, which compresses coefficient planes using a JPEG encoding

Author:
Default

Constructor Summary
JPEGLRGBReader(java.io.InputStream inputStream)
          Creates a new instance of a JPEGLRGBReader from the given InputStream
 
Method Summary
static int[] combine(int[] green, byte[] _blue)
          Combines two coefficient planes
static int[] convert(byte[] a)
          Converts an array of unsigned bytes to integers
static int indexOf(int question, int[] a)
          Returns the index of a given value in an array
static java.awt.image.BufferedImage invert(java.awt.image.BufferedImage source)
          Inverts an image - one of the help functions for unpacking the coefficient planes
static int[] invert(int[] source)
          Inverts a pixel buffer - used for unpacking the coefficient planes
static void main(java.lang.String[] args)
          Main method for testing
 PTM readPTM()
          Calls the read procedure
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPEGLRGBReader

public JPEGLRGBReader(java.io.InputStream inputStream)
Creates a new instance of a JPEGLRGBReader from the given InputStream

Parameters:
inputStream - The input stream used to read the PTM
Method Detail

readPTM

public PTM readPTM()
            throws java.io.IOException
Calls the read procedure

Specified by:
readPTM in interface PTMReader
Returns:
the LRGBPTM
Throws:
java.io.IOException - If the input stream isn't readable

invert

public static java.awt.image.BufferedImage invert(java.awt.image.BufferedImage source)
Inverts an image - one of the help functions for unpacking the coefficient planes

Parameters:
source - the source image
Returns:
an inverted image

invert

public static int[] invert(int[] source)
Inverts a pixel buffer - used for unpacking the coefficient planes

Parameters:
source - the source pixel buffer
Returns:
the inverted buffer

main

public static void main(java.lang.String[] args)
Main method for testing

Parameters:
args - args[0] is the name of a JPEGLRGB file

convert

public static int[] convert(byte[] a)
Converts an array of unsigned bytes to integers

Parameters:
a - the array of unsigned bytes
Returns:
a copy of the source array as integers

combine

public static int[] combine(int[] green,
                            byte[] _blue)
Combines two coefficient planes

Parameters:
green - the first coefficient plane
_blue - the second coefficient plane
Returns:
the combined result

indexOf

public static int indexOf(int question,
                          int[] a)
Returns the index of a given value in an array

Parameters:
question - the value to look for
a - the array to search
Returns:
the (first) index of the value in the array, if found