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.

    Author:
    Paulo Soares
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String cHRM
      A PNG marker.
      static java.lang.String gAMA
      A PNG marker.
      static java.lang.String iCCP
      A PNG marker.
      static java.lang.String IDAT
      A PNG marker.
      static java.lang.String IEND
      A PNG marker.
      static java.lang.String IHDR
      A PNG marker.
      static java.lang.String pHYs
      A PNG marker.
      static java.lang.String PLTE
      A PNG marker.
      static int[] PNGID
      Some PNG specific values.
      static java.lang.String sRGB
      A PNG marker.
      static java.lang.String tRNS
      A PNG marker.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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