com.lowagie.text.pdf.codec

Class 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
static classPngImage.NewByteArrayOutputStream
Field Summary
PdfDictionaryadditional
intbitDepth
intbytesPerPixel
static StringcHRM
A PNG marker.
byte[]colorTable
intcolorType
intcompressionMethod
DataInputStreamdataStream
intdpiX
intdpiY
intfilterMethod
static StringgAMA
A PNG marker.
floatgamma
booleangenBWMask
booleanhasCHRM
intheight
ICC_Profileicc_profile
static StringiCCP
A PNG marker.
PngImage.NewByteArrayOutputStreamidat
byte[]image
intinputBands
PdfNameintent
static PdfName[]intents
intinterlaceMethod
InputStreamis
static StringIDAT
A PNG marker.
static StringIEND
A PNG marker.
static StringIHDR
A PNG marker.
booleanpalShades
static StringpHYs
A PNG marker.
static StringPLTE
A PNG marker.
static int[]PNGID
Some PNG specific values.
static intPNG_FILTER_AVERAGE
static intPNG_FILTER_NONE
static intPNG_FILTER_PAETH
static intPNG_FILTER_SUB
static intPNG_FILTER_UP
byte[]smask
static StringsRGB
A PNG marker.
byte[]trans
inttransBlue
inttransGreen
inttransRedGray
static StringtRNS
A PNG marker.
static intTRANSFERSIZE
intwidth
floatxB
floatxG
floatxR
floatxW
floatXYRatio
floatyB
floatyG
floatyR
floatyW
Constructor Summary
PngImage(InputStream is)
Creates a new instance of PngImage
Method Summary
booleancheckMarker(String s)
static voiddecodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp)
voiddecodeIdat()
static voiddecodePaethFilter(byte[] curr, byte[] prev, int count, int bpp)
voiddecodePass(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight)
static voiddecodeSubFilter(byte[] curr, int count, int bpp)
static voiddecodeUpFilter(byte[] curr, byte[] prev, int count)
PdfObjectgetColorspace()
static ImagegetImage(URL url)
Reads a PNG from an url.
static ImagegetImage(InputStream is)
Reads a PNG from a stream.
static ImagegetImage(String file)
Reads a PNG from a file.
static ImagegetImage(byte[] data)
Reads a PNG from a byte array.
ImagegetImage()
static intgetInt(InputStream is)
Gets an int from an InputStream.
static intgetPixel(byte[] image, int x, int y, int bitDepth, int bytesPerRow)
int[]getPixel(byte[] curr)
static StringgetString(InputStream is)
Gets a String from an InputStream.
static intgetWord(InputStream is)
Gets a word from an InputStream.
static intpaethPredictor(int a, int b, int c)
voidprocessPixels(byte[] curr, int xOffset, int step, int y, int width)
voidreadPng()
static voidsetPixel(byte[] image, int[] data, int offset, int size, int x, int y, int bitDepth, int bytesPerRow)

Field Detail

additional

PdfDictionary additional

bitDepth

int bitDepth

bytesPerPixel

int bytesPerPixel

cHRM

public static final String cHRM
A PNG marker.

colorTable

byte[] colorTable

colorType

int colorType

compressionMethod

int compressionMethod

dataStream

DataInputStream dataStream

dpiX

int dpiX

dpiY

int dpiY

filterMethod

int filterMethod

gAMA

public static final String gAMA
A PNG marker.

gamma

float gamma

genBWMask

boolean genBWMask

hasCHRM

boolean hasCHRM

height

int height

icc_profile

ICC_Profile icc_profile

iCCP

public static final String iCCP
A PNG marker.

idat

PngImage.NewByteArrayOutputStream idat

image

byte[] image

inputBands

int inputBands

intent

PdfName intent

intents

private static final PdfName[] intents

interlaceMethod

int interlaceMethod

is

InputStream is

IDAT

public static final String IDAT
A PNG marker.

IEND

public static final String IEND
A PNG marker.

IHDR

public static final String IHDR
A PNG marker.

palShades

boolean palShades

pHYs

public static final String pHYs
A PNG marker.

PLTE

public static final String PLTE
A PNG marker.

PNGID

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

PNG_FILTER_AVERAGE

private static final int PNG_FILTER_AVERAGE

PNG_FILTER_NONE

private static final int PNG_FILTER_NONE

PNG_FILTER_PAETH

private static final int PNG_FILTER_PAETH

PNG_FILTER_SUB

private static final int PNG_FILTER_SUB

PNG_FILTER_UP

private static final int PNG_FILTER_UP

smask

byte[] smask

sRGB

public static final String sRGB
A PNG marker.

trans

byte[] trans

transBlue

int transBlue

transGreen

int transGreen

transRedGray

int transRedGray

tRNS

public static final String tRNS
A PNG marker.

TRANSFERSIZE

private static final int TRANSFERSIZE

width

int width

xB

float xB

xG

float xG

xR

float xR

xW

float xW

XYRatio

float XYRatio

yB

float yB

yG

float yG

yR

float yR

yW

float yW

Constructor Detail

PngImage

PngImage(InputStream is)
Creates a new instance of PngImage

Method Detail

checkMarker

boolean checkMarker(String s)

decodeAverageFilter

private static void decodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp)

decodeIdat

void decodeIdat()

decodePaethFilter

private static void decodePaethFilter(byte[] curr, byte[] prev, int count, int bpp)

decodePass

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

decodeSubFilter

private static void decodeSubFilter(byte[] curr, int count, int bpp)

decodeUpFilter

private static void decodeUpFilter(byte[] curr, byte[] prev, int count)

getColorspace

PdfObject getColorspace()

getImage

public static Image getImage(URL url)
Reads a PNG from an url.

Parameters: url the url

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(InputStream is)
Reads a PNG from a stream.

Parameters: is the stream

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(String file)
Reads a PNG from a file.

Parameters: file the file

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(byte[] data)
Reads a PNG from a byte array.

Parameters: data the byte array

Returns: the image

Throws: IOException on error

getImage

Image getImage()

getInt

public static final int getInt(InputStream is)
Gets an int from an InputStream.

Parameters: is an InputStream

Returns: the value of an int

getPixel

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

getPixel

int[] getPixel(byte[] curr)

getString

public static final String getString(InputStream is)
Gets a String from an InputStream.

Parameters: is an InputStream

Returns: the value of an int

getWord

public static final int getWord(InputStream is)
Gets a word from an InputStream.

Parameters: is an InputStream

Returns: the value of an int

paethPredictor

private static int paethPredictor(int a, int b, int c)

processPixels

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

readPng

void readPng()

setPixel

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