Class PngEncoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.png.PngEncoder
All Implemented Interfaces:
com.idrsolutions.image.Encoder

public class PngEncoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Encoder
Class writes BufferedImages as Fast deflated Png Example 1:

 PngEncoder encoder = new PngEncoder();
 encoder.write(image, outputStream);
 
Example 2 (with 8 bit quantisation compression):

 PngEncoder encoder = new PngEncoder();
 encoder.getEncoderOptions().setCompressionFormat(PngCompressionFormat.QUANTISED8BIT);
 encoder.write(image, outputStream);
 
  • Field Summary

    Fields inherited from class com.idrsolutions.image.JDeliImage

    bb
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    PngEncoder(com.idrsolutions.image.encoder.options.EncoderOptions format)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    boolean
    Deprecated.
    - use getEncoderOptions().getCompressionFormat().equals(PngCompressionFormat.QUANTISED8BIT); Returns whether Deflate compression is enabled in tiff generation.
    boolean
    Deprecated.
    - use getEncoderOptions().isOptimizeBasedOnColors();
    void
    setCompressed(boolean compress)
    Deprecated.
    - use pngEncoderOptions.setCompressionFormat(PngCompressionFormat pngCompression); setEncoderOptions(pngEncoderOptions);
    void
     
    void
    setOptimizeBasedOnColors(boolean optimizeBasedOnColors)
    Deprecated.
    - use pngEncoderOptions.setOptimizeBasedOnColors(boolean); setEncoderOptions(pngEncoderOptions);
    void
    write(BufferedImage image, File file)
    Writes BufferedImage as a PNG into a file
    void
    write(BufferedImage image, OutputStream outputStream)
    Writes BufferedImage as a PNG into an OutputStream

    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
  • Constructor Details

    • PngEncoder

      public PngEncoder(com.idrsolutions.image.encoder.options.EncoderOptions format)
    • PngEncoder

      public PngEncoder()
  • Method Details

    • write

      public void write(BufferedImage image, OutputStream outputStream) throws IOException
      Writes BufferedImage as a PNG into an OutputStream

      This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

      Specified by:
      write in interface com.idrsolutions.image.Encoder
      Parameters:
      image - BufferedImage to write
      outputStream - The stream to write the image to
      Throws:
      IOException - if the image wasn't written
    • write

      public void write(BufferedImage image, File file) throws IOException
      Writes BufferedImage as a PNG into a file

      Parameters:
      image - BufferedImage to write
      file - The file the image to be written as png
      Throws:
      IOException - if the image wasn't written
    • isCompressed

      @Deprecated public boolean isCompressed()
      Deprecated.
      - use getEncoderOptions().getCompressionFormat().equals(PngCompressionFormat.QUANTISED8BIT); Returns whether Deflate compression is enabled in tiff generation.
      Returns:
      Whether compression is enabled
    • getEncoderOptions

      public PngEncoderOptions getEncoderOptions()
    • setEncoderOptions

      public void setEncoderOptions(PngEncoderOptions pngEncoderOptions)
    • setCompressed

      @Deprecated public void setCompressed(boolean compress)
      Deprecated.
      - use pngEncoderOptions.setCompressionFormat(PngCompressionFormat pngCompression); setEncoderOptions(pngEncoderOptions);
      Set true to enable 8 bit quantisation compression in PNG generation
      Parameters:
      compress - value to determine if compression used
    • isOptimizeBasedOnColors

      @Deprecated public boolean isOptimizeBasedOnColors()
      Deprecated.
      - use getEncoderOptions().isOptimizeBasedOnColors();
      Returns:
      Whether compression feature is enabled
    • setOptimizeBasedOnColors

      @Deprecated public void setOptimizeBasedOnColors(boolean optimizeBasedOnColors)
      Deprecated.
      - use pngEncoderOptions.setOptimizeBasedOnColors(boolean); setEncoderOptions(pngEncoderOptions);
      Parameters:
      optimizeBasedOnColors - value to determine strategy of image optimisation