Class PngImage

java.lang.Object
com.aowagie.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

    • PNGID

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

      private static final String IHDR
      A PNG marker.
      See Also:
    • PLTE

      private static final String PLTE
      A PNG marker.
      See Also:
    • IDAT

      private static final String IDAT
      A PNG marker.
      See Also:
    • IEND

      private static final String IEND
      A PNG marker.
      See Also:
    • tRNS

      private static final String tRNS
      A PNG marker.
      See Also:
    • pHYs

      private static final String pHYs
      A PNG marker.
      See Also:
    • gAMA

      private static final String gAMA
      A PNG marker.
      See Also:
    • cHRM

      private static final String cHRM
      A PNG marker.
      See Also:
    • sRGB

      private static final String sRGB
      A PNG marker.
      See Also:
    • iCCP

      private static final String iCCP
      A PNG marker.
      See Also:
    • TRANSFERSIZE

      private static final int TRANSFERSIZE
      See Also:
    • PNG_FILTER_NONE

      private static final int PNG_FILTER_NONE
      See Also:
    • PNG_FILTER_SUB

      private static final int PNG_FILTER_SUB
      See Also:
    • PNG_FILTER_UP

      private static final int PNG_FILTER_UP
      See Also:
    • PNG_FILTER_AVERAGE

      private static final int PNG_FILTER_AVERAGE
      See Also:
    • PNG_FILTER_PAETH

      private static final int PNG_FILTER_PAETH
      See Also:
    • intents

      private static final PdfName[] intents
    • is

      private final InputStream is
    • dataStream

      private 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
    • additional

      private final PdfDictionary additional
    • image

      private byte[] image
    • smask

      private byte[] smask
    • trans

      private byte[] trans
    • idat

    • 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
    • intent

      private PdfName intent
    • icc_profile

      private ICC_Profile icc_profile
  • Constructor Details

    • PngImage

      private 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

      private 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(byte[] data) throws IOException
      Reads a PNG from a byte array.
      Parameters:
      data - the byte array
      Returns:
      the image
      Throws:
      IOException - on error
    • checkMarker

      private boolean checkMarker(String s)
    • readPng

      private void readPng() throws IOException
      Throws:
      IOException
    • getColorspace

      private PdfObject getColorspace()
    • getImage

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

      private 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

      private 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