com.lowagie.text.pdf.codec
Class PngImage

java.lang.Object
  extended by com.lowagie.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.

Author:
Paulo Soares (psoares@consiste.pt)

Nested Class Summary
(package private) static class PngImage.NewByteArrayOutputStream
           
 
Field Summary
(package private)  PdfDictionary additional
           
(package private)  int bitDepth
           
(package private)  int bytesPerPixel
           
static String cHRM
          A PNG marker.
(package private)  byte[] colorTable
           
(package private)  int colorType
           
(package private)  int compressionMethod
           
(package private)  DataInputStream dataStream
           
(package private)  int dpiX
           
(package private)  int dpiY
           
(package private)  int filterMethod
           
static String gAMA
          A PNG marker.
(package private)  float gamma
           
(package private)  boolean genBWMask
           
(package private)  boolean hasCHRM
           
(package private)  int height
           
(package private)  ICC_Profile icc_profile
           
static String iCCP
          A PNG marker.
(package private)  PngImage.NewByteArrayOutputStream idat
           
static String IDAT
          A PNG marker.
static String IEND
          A PNG marker.
static String IHDR
          A PNG marker.
(package private)  byte[] image
           
(package private)  int inputBands
           
(package private)  PdfName intent
           
private static PdfName[] intents
           
(package private)  int interlaceMethod
           
(package private)  InputStream is
           
(package private)  boolean palShades
           
static String pHYs
          A PNG marker.
static String PLTE
          A PNG marker.
private static int PNG_FILTER_AVERAGE
           
private static int PNG_FILTER_NONE
           
private static int PNG_FILTER_PAETH
           
private static int PNG_FILTER_SUB
           
private static int PNG_FILTER_UP
           
static int[] PNGID
          Some PNG specific values.
(package private)  byte[] smask
           
static String sRGB
          A PNG marker.
(package private)  byte[] trans
           
(package private)  int transBlue
           
private static int TRANSFERSIZE
           
(package private)  int transGreen
           
(package private)  int transRedGray
           
static String tRNS
          A PNG marker.
(package private)  int width
           
(package private)  float xB
           
(package private)  float xG
           
(package private)  float xR
           
(package private)  float xW
           
(package private)  float XYRatio
           
(package private)  float yB
           
(package private)  float yG
           
(package private)  float yR
           
(package private)  float yW
           
 
Constructor Summary
PngImage(InputStream is)
          Creates a new instance of PngImage
 
Method Summary
(package private)  boolean checkMarker(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()
           
(package private)  Image getImage()
           
static Image getImage(byte[] data)
          Reads a PNG from a byte array.
static Image getImage(InputStream is)
          Reads a PNG from a stream.
static Image getImage(String file)
          Reads a PNG from a file.
static Image getImage(URL url)
          Reads a PNG from an url.
static int getInt(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 String getString(InputStream is)
          Gets a String from an InputStream.
static int getWord(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.


IHDR

public static final String IHDR
A PNG marker.

See Also:
Constant Field Values

PLTE

public static final String PLTE
A PNG marker.

See Also:
Constant Field Values

IDAT

public static final String IDAT
A PNG marker.

See Also:
Constant Field Values

IEND

public static final String IEND
A PNG marker.

See Also:
Constant Field Values

tRNS

public static final String tRNS
A PNG marker.

See Also:
Constant Field Values

pHYs

public static final String pHYs
A PNG marker.

See Also:
Constant Field Values

gAMA

public static final String gAMA
A PNG marker.

See Also:
Constant Field Values

cHRM

public static final String cHRM
A PNG marker.

See Also:
Constant Field Values

sRGB

public static final String sRGB
A PNG marker.

See Also:
Constant Field Values

iCCP

public static final String iCCP
A PNG marker.

See Also:
Constant Field Values

TRANSFERSIZE

private static final int TRANSFERSIZE
See Also:
Constant Field Values

PNG_FILTER_NONE

private static final int PNG_FILTER_NONE
See Also:
Constant Field Values

PNG_FILTER_SUB

private static final int PNG_FILTER_SUB
See Also:
Constant Field Values

PNG_FILTER_UP

private static final int PNG_FILTER_UP
See Also:
Constant Field Values

PNG_FILTER_AVERAGE

private static final int PNG_FILTER_AVERAGE
See Also:
Constant Field Values

PNG_FILTER_PAETH

private static final int PNG_FILTER_PAETH
See Also:
Constant Field Values

intents

private static final PdfName[] intents

is

InputStream is

dataStream

DataInputStream dataStream

width

int width

height

int height

bitDepth

int bitDepth

colorType

int colorType

compressionMethod

int compressionMethod

filterMethod

int filterMethod

interlaceMethod

int interlaceMethod

additional

PdfDictionary additional

image

byte[] image

smask

byte[] smask

trans

byte[] trans

idat

PngImage.NewByteArrayOutputStream idat

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

intent

PdfName intent

icc_profile

ICC_Profile icc_profile
Constructor Detail

PngImage

PngImage(InputStream is)
Creates a new instance of PngImage

Method Detail

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)

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

Hosted by Hostbasket