Class PngImage


  • public class PngImage
    extends java.lang.Object
    Reads a PNG image. All types of PNG can be read.

    It is based in part in the JAI codec.

    • Field Detail

      • PNGID

        public static final int[] PNGID
        Some PNG specific values.
      • intents

        private static final PdfName[] intents
      • is

        private final java.io.InputStream is
      • dataStream

        private java.io.DataInputStream dataStream
      • width

        private int width
      • height

        private int height
      • bitDepth

        private int bitDepth
      • colorType

        private int colorType
      • compressionMethod

        private int compressionMethod
      • filterMethod

        private int filterMethod
      • interlaceMethod

        private int interlaceMethod
      • image

        private byte[] image
      • smask

        private byte[] smask
      • trans

        private byte[] trans
      • dpiX

        private int dpiX
      • dpiY

        private int dpiY
      • XYRatio

        private float XYRatio
      • genBWMask

        private boolean genBWMask
      • palShades

        private boolean palShades
      • transRedGray

        private int transRedGray
      • transGreen

        private int transGreen
      • transBlue

        private int transBlue
      • inputBands

        private int inputBands
      • bytesPerPixel

        private int bytesPerPixel
      • colorTable

        private byte[] colorTable
      • gamma

        private float gamma
      • hasCHRM

        private boolean hasCHRM
      • xW

        private float xW
      • yW

        private float yW
      • xR

        private float xR
      • yR

        private float yR
      • xG

        private float xG
      • yG

        private float yG
      • xB

        private float xB
      • yB

        private float yB
      • icc_profile

        private java.awt.color.ICC_Profile icc_profile
    • Constructor Detail

      • PngImage

        private PngImage​(java.io.InputStream is)
        Creates a new instance of PngImage
    • Method Detail

      • getImage

        public static Image getImage​(java.net.URL url)
                              throws java.io.IOException
        Reads a PNG from an url.
        Parameters:
        url - the url
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        private static Image getImage​(java.io.InputStream is)
                               throws java.io.IOException
        Reads a PNG from a stream.
        Parameters:
        is - the stream
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        public static Image getImage​(byte[] data)
                              throws java.io.IOException
        Reads a PNG from a byte array.
        Parameters:
        data - the byte array
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • checkMarker

        private boolean checkMarker​(java.lang.String s)
      • readPng

        private void readPng()
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • getColorspace

        private PdfObject getColorspace()
      • getImage

        private Image getImage()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeIdat

        private void decodeIdat()
      • decodePass

        private void decodePass​(int xOffset,
                                int yOffset,
                                int xStep,
                                int yStep,
                                int passWidth,
                                int passHeight)
      • processPixels

        private void processPixels​(byte[] curr,
                                   int xOffset,
                                   int step,
                                   int y,
                                   int width)
      • setPixel

        private static void setPixel​(byte[] image,
                                     int[] data,
                                     int offset,
                                     int size,
                                     int x,
                                     int y,
                                     int bitDepth,
                                     int bytesPerRow)
      • getPixel

        private int[] getPixel​(byte[] curr)
      • decodeSubFilter

        private static void decodeSubFilter​(byte[] curr,
                                            int count,
                                            int bpp)
      • decodeUpFilter

        private static void decodeUpFilter​(byte[] curr,
                                           byte[] prev,
                                           int count)
      • decodeAverageFilter

        private static void decodeAverageFilter​(byte[] curr,
                                                byte[] prev,
                                                int count,
                                                int bpp)
      • paethPredictor

        private static int paethPredictor​(int a,
                                          int b,
                                          int c)
      • decodePaethFilter

        private static void decodePaethFilter​(byte[] curr,
                                              byte[] prev,
                                              int count,
                                              int bpp)
      • getInt

        private static final int getInt​(java.io.InputStream is)
                                 throws java.io.IOException
        Gets an int from an InputStream.
        Parameters:
        is - an InputStream
        Returns:
        the value of an int
        Throws:
        java.io.IOException
      • getWord

        private static final int getWord​(java.io.InputStream is)
                                  throws java.io.IOException
        Gets a word from an InputStream.
        Parameters:
        is - an InputStream
        Returns:
        the value of an int
        Throws:
        java.io.IOException
      • getString

        private static final java.lang.String getString​(java.io.InputStream is)
                                                 throws java.io.IOException
        Gets a String from an InputStream.
        Parameters:
        is - an InputStream
        Returns:
        the value of an int
        Throws:
        java.io.IOException