Package rma.util.png
Class PngEncoderB
java.lang.Object
rma.util.png.PngEncoder
rma.util.png.PngEncoderB
-
Field Summary
FieldsFields inherited from class rma.util.png.PngEncoder
bytePos, bytesPerPixel, compressionLevel, crc, crcValue, dataPos, ENCODE_ALPHA, encodeAlpha, endPos, filter, FILTER_LAST, FILTER_NONE, FILTER_SUB, FILTER_UP, hdrPos, height, leftBytes, maxPos, NO_ALPHA, pngBytes, priorRow, width
-
Constructor Summary
ConstructorsConstructorDescriptionClass constructorPngEncoderB
(BufferedImage image) Class constructor specifying BufferedImage to encode, with no alpha channel encoding.PngEncoderB
(BufferedImage image, boolean encodeAlpha) Class constructor specifying BufferedImage to encode, and whether to encode alpha.PngEncoderB
(BufferedImage image, boolean encodeAlpha, int whichFilter) Class constructor specifying BufferedImage to encode, whether to encode alpha, and filter to use.PngEncoderB
(BufferedImage image, boolean encodeAlpha, int whichFilter, int compLevel) Class constructor specifying BufferedImage source to encode, whether to encode alpha, filter to use, and compression level -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Get and set variables that determine how picture is stored.byte[]
Creates an array of bytes that is the PNG equivalent of the current image.byte[]
pngEncode
(boolean encodeAlpha) Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not.void
setImage
(BufferedImage image) Set the BufferedImage to be encodedprotected void
Write a PNG "IHDR" chunk into the pngBytes array.protected boolean
Write the image data into the pngBytes array.protected void
Methods inherited from class rma.util.png.PngEncoder
filterSub, filterUp, getCompressionLevel, getEncodeAlpha, getFilter, resizeByteArray, setCompressionLevel, setEncodeAlpha, setFilter, setImage, writeByte, writeBytes, writeBytes, writeEnd, writeInt2, writeInt4, writeString
-
Field Details
-
image
-
wRaster
-
tType
protected int tType
-
-
Constructor Details
-
PngEncoderB
public PngEncoderB()Class constructor -
PngEncoderB
Class constructor specifying BufferedImage to encode, with no alpha channel encoding.- Parameters:
image
- A Java BufferedImage object
-
PngEncoderB
Class constructor specifying BufferedImage to encode, and whether to encode alpha.- Parameters:
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yes
-
PngEncoderB
Class constructor specifying BufferedImage to encode, whether to encode alpha, and filter to use.- Parameters:
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=up
-
PngEncoderB
Class constructor specifying BufferedImage source to encode, whether to encode alpha, filter to use, and compression level- Parameters:
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=upcompLevel
- 0..9
-
-
Method Details
-
setImage
Set the BufferedImage to be encoded- Parameters:
image
- A Java BufferedImage object
-
pngEncode
public byte[] pngEncode(boolean encodeAlpha) Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not.- Overrides:
pngEncode
in classPngEncoder
- Parameters:
encodeAlpha
- boolean false=no alpha, true=encode alpha- Returns:
- an array of bytes, or null if there was a problem
-
pngEncode
public byte[] pngEncode()Creates an array of bytes that is the PNG equivalent of the current image. Alpha encoding is determined by its setting in the constructor.- Overrides:
pngEncode
in classPngEncoder
- Returns:
- an array of bytes, or null if there was a problem
-
establishStorageInfo
protected boolean establishStorageInfo()Get and set variables that determine how picture is stored. Retrieves the writable raster of the buffered image, as well its transfer type. Sets number of output bytes per pixel, and, if only eight-bit bytes, turns off alpha encoding.- Returns:
- true if 1-byte or 4-byte data, false otherwise
-
writeHeader
protected void writeHeader()Write a PNG "IHDR" chunk into the pngBytes array.- Overrides:
writeHeader
in classPngEncoder
-
writePalette
-
writeImageData
protected boolean writeImageData()Write the image data into the pngBytes array. This will write one or more PNG "IDAT" chunks. In order to conserve memory, this method grabs as many rows as will fit into 32K bytes, or the whole image; whichever is less.- Overrides:
writeImageData
in classPngEncoder
- Returns:
- true if no errors; false if error grabbing pixels
-