Interface | Description |
---|---|
IBytesConsumer |
Bytes consumer.
|
IChunkFactory | |
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 . |
IPngWriterFactory |
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 . |
ChunkSeqBuffering |
This loads the png as a plain sequence of chunks, buffering all
Useful to do things like insert or delete a ancilllary chunk.
|
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.
|
ChunkSeqSkipping |
This simple reader skips all chunks contents and stores the chunkRaw in a list.
|
DeflatedChunkReader |
Specialization of ChunkReader, for IDAT-like chunks.
|
DeflatedChunksSet |
A set of IDAT-like chunks which, concatenated, form a zlib stream.
|
Deinterlacer | |
IDatChunkWriter |
Outputs a sequence of IDAT-like chunk, that is filled progressively until the max chunk length is reached (or until
flush())
|
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.
|
PngReaderApng | |
PngReaderByte |
Trivial extension of
PngReader that uses ImageLineByte |
PngReaderFilter |
This class allows to use a simple PNG reader as an input filter, wrapping a ChunkSeqReaderPng in callback mode.
|
PngReaderInt |
Trivial extension of
PngReader that uses ImageLineInt . |
PngWriter |
Writes a PNG image, line by line.
|
PngWriterHc |
Pngwriter with High compression EXPERIMENTAL
|
Enum | Description |
---|---|
ChunkReader.ChunkReaderMode |
Modes of ChunkReader chunk processing.
|
FilterType |
Internal PNG predictor filter type
Negative values are pseudo types, actually global strategies for writing, that (can) result on different real filters
for different rows
|
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) { // you can also use PngReader (esentially the same) or PngReaderByte PngReaderInt pngr = new PngReaderInt(new File(origFilename)); System.out.println(pngr.toString()); int channels = pngr.imgInfo.channels; if (channels < 3 || pngr.imgInfo.bitDepth != 8) throw new RuntimeException("For simplicity this supports only RGB8/RGBA8 images"); // writer with same image properties as original PngWriter pngw = new PngWriter(new File(destFilename), pngr.imgInfo, true); // instruct the writer to grab all ancillary chunks from the original pngw.copyChunksFrom(pngr.getChunksList(), ChunkCopyBehaviour.COPY_ALL_SAFE); // add a textual chunk to writer pngw.getMetadata().setText(PngChunkTextVar.KEY_Description, "Decreased red and increased green"); // also: while(pngr.hasMoreRows()) for (int row = 0; row < pngr.imgInfo.rows; row++) { ImageLineInt l1 = pngr.readRowInt(); // each element is a sample int[] scanline = 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 © 2014. All rights reserved.