Class PngDecoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.png.PngDecoder
All Implemented Interfaces:
com.idrsolutions.image.Decoder

public class PngDecoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Decoder
Class reads PNG images as BufferedImage // Make NO assumptions about type of BufferedImage type returned (may change) Example 1 (Using raw byte data):

 PngDecoder decoder = new PngDecoder();
 BufferedImage decodedImage = decoder.read(pngByteData);
 
Example 2 (Using File):

 File pngFile = new File("C:\\path\\to\\output\\file.png");
 PngDecoder decoder = new PngDecoder();
 BufferedImage decodedImage = decoder.read(pngFile);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    read(byte[] pngRawData)
    Decodes and returns the PNG image as a BufferedImage from bytes
    read(File file)
    Decodes and returns the PNG image as a BufferedImage from a File
    readDimension(byte[] pngRawData)
    Decodes and returns the width and height of png image
    Decodes and returns the width and height of png image

    Methods inherited from class com.idrsolutions.image.JDeliImage

    optimiseImage

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.idrsolutions.image.Decoder

    getImageCount, getImageCount, readEmbeddedThumbnail, readEmbeddedThumbnail, readImageAt, readImageAt, readImageSpecificMetaData, readImageSpecificMetaData, setMetadata
  • Constructor Details

    • PngDecoder

      public PngDecoder()
  • Method Details

    • read

      public BufferedImage read(byte[] pngRawData) throws Exception
      Decodes and returns the PNG image as a BufferedImage from bytes
      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      pngRawData - byte[] containing the PNG 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
      Decodes and returns the PNG image as a BufferedImage from a File
      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      file - input image file to be decoded
      Returns:
      BufferedImage 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 png 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[] pngRawData) throws Exception
      Decodes and returns the width and height of png image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      pngRawData - image image contained in raw data if present
      Returns:
      Rectangle width and height of image
      Throws:
      Exception - if problem reading image