Class PngImage

java.lang.Object
com.itextpdf.text.pdf.codec.PngImage

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

It is based in part in the JAI codec.

  • Field Details

  • Constructor Details

    • PngImage

      PngImage(InputStream is)
      Creates a new instance of PngImage
  • Method Details

    • getImage

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

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

      public static Image getImage(String file) throws IOException
      Reads a PNG from a file.
      Parameters:
      file - the file
      Returns:
      the image
      Throws:
      IOException - on error
    • getImage

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

      boolean checkMarker(String s)
    • readPng

      void readPng() throws IOException
      Throws:
      IOException
    • getColorspace

      PdfObject getColorspace()
    • getImage

      Image getImage() throws IOException
      Throws:
      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(InputStream is) throws IOException
      Gets an int from an InputStream.
      Parameters:
      is - an InputStream
      Returns:
      the value of an int
      Throws:
      IOException
    • getWord

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

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