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.

    • Constructor Summary

      Constructors 
      Constructor Description
      PngImage​(java.io.InputStream is)
      Creates a new instance of PngImage
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkIccProfile()  
      (package private) boolean checkMarker​(java.lang.String s)  
      private static void decodeAverageFilter​(byte[] curr, byte[] prev, int count, int bpp)  
      (package private) void decodeIdat()  
      private static void decodePaethFilter​(byte[] curr, byte[] prev, int count, int bpp)  
      (package private) void decodePass​(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight)  
      private static void decodeSubFilter​(byte[] curr, int count, int bpp)  
      private static void decodeUpFilter​(byte[] curr, byte[] prev, int count)  
      (package private) PdfObject getColorspace()  
      private int getExpectedIccNumberOfComponents()  
      (package private) Image getImage()  
      static Image getImage​(byte[] data)
      Reads a PNG from a byte array.
      static Image getImage​(java.io.InputStream is)
      Reads a PNG from a stream.
      static Image getImage​(java.lang.String file)
      Reads a PNG from a file.
      static Image getImage​(java.net.URL url)
      Reads a PNG from an url.
      static int getInt​(java.io.InputStream is)
      Gets an int from an InputStream.
      (package private) int[] getPixel​(byte[] curr)  
      (package private) static int getPixel​(byte[] image, int x, int y, int bitDepth, int bytesPerRow)  
      static java.lang.String getString​(java.io.InputStream is)
      Gets a String from an InputStream.
      static int getWord​(java.io.InputStream is)
      Gets a word from an InputStream.
      private static int paethPredictor​(int a, int b, int c)  
      (package private) void processPixels​(byte[] curr, int xOffset, int step, int y, int width)  
      (package private) void readPng()  
      (package private) static void setPixel​(byte[] image, int[] data, int offset, int size, int x, int y, int bitDepth, int bytesPerRow)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PNGID

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

        private static final PdfName[] intents
      • is

        java.io.InputStream is
      • dataStream

        java.io.DataInputStream dataStream
      • width

        int width
      • height

        int height
      • bitDepth

        int bitDepth
      • colorType

        int colorType
      • compressionMethod

        int compressionMethod
      • filterMethod

        int filterMethod
      • interlaceMethod

        int interlaceMethod
      • image

        byte[] image
      • smask

        byte[] smask
      • trans

        byte[] trans
      • dpiX

        int dpiX
      • dpiY

        int dpiY
      • XYRatio

        float XYRatio
      • genBWMask

        boolean genBWMask
      • palShades

        boolean palShades
      • transRedGray

        int transRedGray
      • transGreen

        int transGreen
      • transBlue

        int transBlue
      • inputBands

        int inputBands
      • bytesPerPixel

        int bytesPerPixel
      • colorTable

        byte[] colorTable
      • gamma

        float gamma
      • hasCHRM

        boolean hasCHRM
      • xW

        float xW
      • yW

        float yW
      • xR

        float xR
      • yR

        float yR
      • xG

        float xG
      • yG

        float yG
      • xB

        float xB
      • yB

        float yB
    • Constructor Detail

      • PngImage

        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

        public 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​(java.lang.String file)
                              throws java.io.IOException
        Reads a PNG from a file.
        Parameters:
        file - the file
        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

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

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

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

        void decodeIdat()
      • decodePass

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

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

        static int getPixel​(byte[] image,
                            int x,
                            int y,
                            int bitDepth,
                            int bytesPerRow)
      • setPixel

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

        int[] getPixel​(byte[] curr)
      • getExpectedIccNumberOfComponents

        private int getExpectedIccNumberOfComponents()
      • checkIccProfile

        private void checkIccProfile()
      • 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

        public 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

        public 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

        public 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