| Interface | Description |
|---|---|
| IBytesConsumer |
Bytes consumer.
|
| IChunkFactory | |
| IFilterWriteStrategy |
Abstracts the strategy usdd by
PngWriter to choose the PNG predictor
filter for each line. |
| IImageLine |
General format-translated image line.
|
| IImageLineArray |
This interface is just for the sake of unifying some methods of
ImageLineHelper that can use both ImageLineInt or
ImageLineByte. |
| IImageLineFactory<T extends IImageLine> |
Image Line factory.
|
| IImageLineSet<T extends IImageLine> |
Set of
IImageLine elements. |
| IImageLineSetFactory<T extends IImageLine> |
Factory of
IImageLineSet, used by PngReader. |
| Class | Description |
|---|---|
| BufferedStreamFeeder |
Reads bytes from an input stream, and feeds a IBytesConsumer.
|
| ChunkReader |
Parses a PNG chunk, consuming bytes in one mode:
ChunkReader.ChunkReaderMode.BUFFER, ChunkReader.ChunkReaderMode.PROCESS,
ChunkReader.ChunkReaderMode.SKIP. |
| ChunkReaderFilter |
This class allows to use a simple PNG reader as an input filter, wrapping a
ChunkSeqReaderPng in callback mode.
|
| ChunkSeqReader |
Consumes a stream of bytes that consist of a series of PNG-like chunks.
|
| ChunkSeqReaderPng |
Adds to ChunkSeqReader the storing of PngChunk, with a PngFactory, and
imageInfo + deinterlacer.
|
| DeflatedChunkReader |
Specialization of ChunkReader, for IDAT-like chunks.
|
| DeflatedChunksSet |
A set of IDAT-like chunks which, concatenated, form a zlib stream.
|
| FilterWriteStrategy |
Manages the writer strategy for selecting the internal png predictor filter
TODO: this needs work
|
| IdatSet |
This object process the concatenation of IDAT chunks.
|
| ImageInfo |
Simple immutable wrapper for basic image info.
|
| ImageLineByte |
Lightweight wrapper for an image scanline, used for read and write.
|
| ImageLineHelper |
Bunch of utility static methods to proces an image line at the pixel level.
|
| ImageLineInt |
Represents an image line, integer format (one integer by sample).
|
| ImageLineSetDefault<T extends IImageLine> |
Default implementation of
IImageLineSet. |
| PngHelperInternal |
Some utility static methods for internal use.
|
| PngReader |
Reads a PNG image (pixels and/or metadata) from a file or stream.
|
| PngReaderByte |
Trivial extension of
PngReader that uses ImageLineByte |
| PngReaderDummy |
Sample implementation of a very basic reader that only loads the empty chunks
|
| PngReaderInt |
Trivial extension of
PngReader that uses ImageLineInt. |
| PngWriter |
Writes a PNG image, line by line.
|
| Enum | Description |
|---|---|
| ChunkReader.ChunkReaderMode |
Modes of ChunkReader chunk processing.
|
| FilterType |
Internal PNG predictor filter
Negative values do not actually represent filter types but "strategies"
|
| Exception | Description |
|---|---|
| PngjBadCrcException |
Exception thrown by bad CRC check
|
| PngjException |
Generic exception for this library.
|
| PngjExceptionInternal |
Exception for anomalous internal problems (sort of asserts) that point to
some issue with the library
|
| PngjInputException |
Exception thrown when reading a PNG.
|
| PngjOutputException |
Exception thrown by writing process
|
| PngjUnsupportedException |
Exception thrown because of some valid feature of PNG standard that this
library does not support.
|
PNGJ main package
Users of this library should rarely need more than the public members of this package.
Newcomers: start with PngReader and PngWriter.
Example of use: this code reads a true colour PNG image (RGB8 or RGBA8) and reduces the red channel by half, increasing the green by 20. It copies all the "safe" metadata from the original image, and adds a textual metadata.
public static void convert(String origFilename, String destFilename) {
PngReader pngr = new PngReader(new File(origFilename));
System.out.println(pngr.toString());
int channels = pngr.imgInfo.channels;
if (channels < 3 || pngr.imgInfo.bitDepth != 8)
throw new RuntimeException("This method is for RGB8/RGBA8 images");
PngWriter pngw = new PngWriter(new File(destFilename), pngr.imgInfo, true);
pngw.copyChunksFrom(pngr.getChunksList(), ChunkCopyBehaviour.COPY_ALL_SAFE);
pngw.getMetadata().setText(PngChunkTextVar.KEY_Description, "Decreased red and increased green");
for (int row = 0; row < pngr.imgInfo.rows; row++) { // also: while(pngr.hasMoreRows())
IImageLine l1 = pngr.readRow();
int[] scanline = ((ImageLineInt) l1).getScanline(); // to save typing
for (int j = 0; j < pngr.imgInfo.cols; j++) {
scanline[j * channels] /= 2;
scanline[j * channels + 1] = ImageLineHelper.clampTo_0_255(scanline[j * channels + 1] + 20);
}
pngw.writeRow(l1);
}
pngr.end(); // it's recommended to end the reader first, in case there are trailing chunks to read
pngw.end();
}
For more examples, see the tests and samples.
Copyright © 2013. All rights reserved.