se.lth.cs.jpeg
Class JPEGDecoder

java.lang.Object
  |
  +--se.lth.cs.jpeg.JPEGDecoder

public class JPEGDecoder
extends java.lang.Object

Provides functionality to decode JPEG images and convert them directly to java.awt.Image objects or to raw pixel bytes.


Constructor Summary
JPEGDecoder()
           
 
Method Summary
static void decodeARGB(byte[] jpegBytes, byte[] pixelBytes)
          Decodes a JPEG encoded image and returns the decoded pixels in alphaBGR format, suitable for efficient graphics display.
static void decodeARGB(byte[] jpegBytes, long pixelMemory)
          Decodes a JPEG encoded image, stores the decoded pixels (in alphaBGR format) in native memory pointed to by the pixelMemory pointer.
static java.awt.Image decodeImage(byte[] jpegBytes)
           Decodes a JPEG encoded image and returns a java.awt.Image object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPEGDecoder

public JPEGDecoder()
Method Detail

decodeImage

public static java.awt.Image decodeImage(byte[] jpegBytes)

Decodes a JPEG encoded image and returns a java.awt.Image object. This object can be used directly by AWT in e.g. a window.

Some AWT methods return before the JPEG decompression is complete (e.g. Toolkit.createImage()). This method, on the other hand, will NOT return until the image is completely constructed and decompressed.

Returns:
Image object based on decoded JPEG image
Throws:
java.lang.IllegalArgumentException - If the image is incorrectly JPEG encoded

decodeARGB

public static void decodeARGB(byte[] jpegBytes,
                              byte[] pixelBytes)
Decodes a JPEG encoded image and returns the decoded pixels in alphaBGR format, suitable for efficient graphics display.


decodeARGB

public static void decodeARGB(byte[] jpegBytes,
                              long pixelMemory)
Decodes a JPEG encoded image, stores the decoded pixels (in alphaBGR format) in native memory pointed to by the pixelMemory pointer. Note, be sure that the pointer is correct and that the memory is properly sized; passing a faulty argument here breaks the safety of Java. This method improves performance by avoiding the need to copy the pixels for display.