Class PNGImageEncoder

  • All Implemented Interfaces:
    ImageEncoder

    public class PNGImageEncoder
    extends ImageEncoderImpl
    An ImageEncoder for the PNG file format.
    Since:
    EA4
    Version:
    $Id: PNGImageEncoder.java 1804130 2017-08-04 14:41:11Z ssteiner $
    • Field Detail

      • magic

        private static final byte[] magic
      • image

        private java.awt.image.RenderedImage image
      • width

        private int width
      • height

        private int height
      • bitDepth

        private int bitDepth
      • bitShift

        private int bitShift
      • numBands

        private int numBands
      • colorType

        private int colorType
      • bpp

        private int bpp
      • skipAlpha

        private boolean skipAlpha
      • compressGray

        private boolean compressGray
      • interlace

        private boolean interlace
      • redPalette

        private byte[] redPalette
      • greenPalette

        private byte[] greenPalette
      • bluePalette

        private byte[] bluePalette
      • alphaPalette

        private byte[] alphaPalette
      • dataOutput

        private java.io.DataOutputStream dataOutput
      • prevRow

        private byte[] prevRow
      • currRow

        private byte[] currRow
      • filteredRows

        private byte[][] filteredRows
      • srgbChroma

        private static final float[] srgbChroma
    • Constructor Detail

      • PNGImageEncoder

        public PNGImageEncoder​(java.io.OutputStream output,
                               PNGEncodeParam param)
    • Method Detail

      • writeMagic

        private void writeMagic()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIHDR

        private void writeIHDR()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • clamp

        private static int clamp​(int val,
                                 int maxValue)
      • encodePass

        private void encodePass​(java.io.OutputStream os,
                                java.awt.image.Raster ras,
                                int xOffset,
                                int yOffset,
                                int xSkip,
                                int ySkip)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIDAT

        private void writeIDAT()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIEND

        private void writeIEND()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCHRM

        private void writeCHRM()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeGAMA

        private void writeGAMA()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeICCP

        private void writeICCP()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSBIT

        private void writeSBIT()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSRGB

        private void writeSRGB()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writePLTE

        private void writePLTE()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBKGD

        private void writeBKGD()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeHIST

        private void writeHIST()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTRNS

        private void writeTRNS()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writePHYS

        private void writePHYS()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSPLT

        private void writeSPLT()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTIME

        private void writeTIME()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTEXT

        private void writeTEXT()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeZTXT

        private void writeZTXT()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writePrivateChunks

        private void writePrivateChunks()
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • createGrayParam

        private PNGEncodeParam.Gray createGrayParam​(byte[] redPalette,
                                                    byte[] greenPalette,
                                                    byte[] bluePalette,
                                                    byte[] alphaPalette)
        Analyzes a set of palettes and determines if it can be expressed as a standard set of gray values, with zero or one values being fully transparent and the rest being fully opaque. If it is possible to express the data thusly, the method returns a suitable instance of PNGEncodeParam.Gray; otherwise it returns null.
      • encode

        public void encode​(java.awt.image.RenderedImage im)
                    throws java.io.IOException
        This method encodes a RenderedImage into PNG. The stream into which the PNG is dumped is not closed at the end of the operation, this should be done if needed by the caller of this method.
        Specified by:
        encode in interface ImageEncoder
        Specified by:
        encode in class ImageEncoderImpl
        Throws:
        java.io.IOException