Class JpegDecoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.jpeg.JpegDecoder
All Implemented Interfaces:
com.idrsolutions.image.Decoder

public class JpegDecoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Decoder
Class reads JPEG image as BufferedImage // Make NO assumptions about type of BufferedImage type returned (may change)

Example:


     JpegDecoder decoder = new JpegDecoder();
     BufferedImage decodedImage = decoder.read(jpegByteData);
 
  • Field Details

    • ZIGZAGORDER

      public static final byte[] ZIGZAGORDER
  • Constructor Details

    • JpegDecoder

      public JpegDecoder()
  • Method Details

    • read

      public BufferedImage read(byte[] jpegRawData) throws Exception
      Make NO assumptions about BufferedImage type returned as it may change

      Decodes and returns the JPEG image as a BufferedImage from bytes

      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      jpegRawData - byte[] containing the JPEG data to be decoded
      Returns:
      BufferedImage The decoded image
      Throws:
      Exception - if an error occurs in reading image
    • read

      public BufferedImage read(File file) throws Exception
      Make NO assumptions about BufferedImage type returned as it may change

      Decodes and returns the JPEG image as a BufferedImage from bytes

      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      file - file containing the JPEG data to be decoded
      Returns:
      BufferedImage The decoded image
      Throws:
      Exception - if an error occurs in reading image
    • readDimension

      public Rectangle readDimension(File file) throws Exception
      Decodes and returns the width and height of jpeg image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      file - image image contained in raw data if present
      Returns:
      width and height of image
      Throws:
      Exception - if problem reading image
    • readDimension

      public Rectangle readDimension(byte[] jpegRawData) throws Exception
      Decodes and returns the width and height of jpeg image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      jpegRawData - image image contained in raw data if present
      Returns:
      Rectangle width and height of image
      Throws:
      Exception - if problem reading image
    • readEmbeddedThumbnail

      public BufferedImage readEmbeddedThumbnail(File file) throws Exception
      Decodes and returns the thumbnail heic image as BufferedImage if there is an thumbnail otherwise returns null
      Specified by:
      readEmbeddedThumbnail in interface com.idrsolutions.image.Decoder
      Parameters:
      file - jpeg file
      Returns:
      BufferedImage thumbnail image
      Throws:
      Exception - if problem reading image
    • readEmbeddedThumbnail

      public BufferedImage readEmbeddedThumbnail(byte[] data) throws Exception
      Decodes and returns the thumbnail heic image as BufferedImage if there is an thumbnail otherwise returns null
      Specified by:
      readEmbeddedThumbnail in interface com.idrsolutions.image.Decoder
      Parameters:
      data - jpeg bytes
      Returns:
      BufferedImage thumbnail image
      Throws:
      Exception - if problem reading image
    • readImageSpecificMetaData

      public void readImageSpecificMetaData(byte[] bytes, Metadata metadata) throws Exception
      Read JPEG specific metadata
      Specified by:
      readImageSpecificMetaData in interface com.idrsolutions.image.Decoder
      Parameters:
      bytes - byte array to read data from
      metadata - image metadata object to hold all metadata
      Throws:
      Exception
    • readImageSpecificMetaData

      public void readImageSpecificMetaData(File file, Metadata metadata) throws Exception
      Read JPEG specific metadata
      Specified by:
      readImageSpecificMetaData in interface com.idrsolutions.image.Decoder
      Parameters:
      file - file to read from
      metadata - image metadata object to hold all metadata
      Throws:
      Exception
    • readComponentsAsRawBytes

      public byte[] readComponentsAsRawBytes(byte[] jpegRawData) throws Exception
      Not recommended for external use.

      Decodes JPEG image data as non converted bytes. Please note this method does not perform YCBCR/CMYK/YCCK to RGB/gray conversion.

      Parameters:
      jpegRawData - byte[] containing the raw JPEG data
      Returns:
      byte[] YCBCR converted data of the JPEG
      Throws:
      Exception - Provides for different exceptions thrown under the Java.Lang package
    • readAsUnconvertedBytes

      public byte[] readAsUnconvertedBytes(byte[] jpegRawData, int adobeColorTransform, com.idrsolutions.image.jpeg.data.Info info) throws Exception
      Not recommended for external use.

      Decodes JPEG image data as un-converted(RGB/gray) bytes

      Parameters:
      jpegRawData - byte[] array containing the un-converted JPEG bytes
      adobeColorTransform - colorspace as defined by Adobe spec
      info - values found in image header
      Returns:
      converted JPEG byte[]
      Throws:
      Exception - Provides for different exceptions thrown under java Lang package
    • decodeSamplesWithOutputBytes

      public static void decodeSamplesWithOutputBytes(com.idrsolutions.image.jpeg.data.Info info, byte[] output)