| java.lang.Object com.keypoint.PngEncoder
All known Subclasses: com.keypoint.PngEncoderB,
Constructor Summary | |
public | PngEncoder() | public | PngEncoder(Image image) Class constructor specifying Image to encode, with no alpha channel encoding. | public | PngEncoder(Image image, boolean encodeAlpha) Class constructor specifying Image to encode, and whether to encode alpha. | public | PngEncoder(Image image, boolean encodeAlpha, int whichFilter) Class constructor specifying Image to encode, whether to encode alpha, and filter to use. | public | PngEncoder(Image image, boolean encodeAlpha, int whichFilter, int compLevel) Class constructor specifying Image source to encode, whether to encode alpha, filter to use, and compression level. |
Method Summary | |
protected void | filterSub(byte[] pixels, int startPos, int width) Perform "sub" filtering on the given row.
Uses temporary array leftBytes to store the original values
of the previous pixels. | protected void | filterUp(byte[] pixels, int startPos, int width) Perform "up" filtering on the given row. | public int | getCompressionLevel() | public boolean | getEncodeAlpha() Retrieve alpha encoding status. | public int | getFilter() | 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. | public byte[] | pngEncode() Creates an array of bytes that is the PNG equivalent of the current image. | protected byte[] | resizeByteArray(byte[] array, int newLength) Increase or decrease the length of a byte array.
Parameters: array - The original array. Parameters: newLength - The length you wish the new array to have. | public void | setCompressionLevel(int level) | public void | setEncodeAlpha(boolean encodeAlpha) Set the alpha encoding on or off. | public void | setFilter(int whichFilter) | public void | setImage(Image image) | protected int | writeByte(int b, int offset) Write a single byte into the pngBytes array at a given position.
Parameters: b - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. | protected int | writeBytes(byte[] data, int offset) Write an array of bytes into the pngBytes array.
Note: This routine has the side effect of updating
maxPos, the largest element written in the array.
The array is resized by 1000 bytes or the length
of the data to be written, whichever is larger.
Parameters: data - The data to be written into pngBytes. Parameters: offset - The starting point to write to. | protected int | writeBytes(byte[] data, int nBytes, int offset) Write an array of bytes into the pngBytes array, specifying number of bytes to write.
Note: This routine has the side effect of updating
maxPos, the largest element written in the array.
The array is resized by 1000 bytes or the length
of the data to be written, whichever is larger.
Parameters: data - The data to be written into pngBytes. Parameters: nBytes - The number of bytes to be written. Parameters: offset - The starting point to write to. | protected void | writeEnd() Write a PNG "IEND" chunk into the pngBytes array. | protected void | writeHeader() Write a PNG "IHDR" chunk into the pngBytes array. | protected boolean | writeImageData() Write the image data into the pngBytes array.
This will write one or more PNG "IDAT" chunks. | protected int | writeInt2(int n, int offset) Write a two-byte integer into the pngBytes array at a given position.
Parameters: n - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. | protected int | writeInt4(int n, int offset) Write a four-byte integer into the pngBytes array at a given position.
Parameters: n - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. | protected int | writeString(String s, int offset) Write a string into the pngBytes array at a given position.
This uses the getBytes method, so the encoding used will
be its default.
Parameters: s - The string to be written into pngBytes. Parameters: offset - The starting point to write to. |
ENCODE_ALPHA | final public static boolean ENCODE_ALPHA(Code) | | Constant specifying that alpha channel should be encoded.
|
FILTER_LAST | final public static int FILTER_LAST(Code) | | |
FILTER_NONE | final public static int FILTER_NONE(Code) | | Constants for filters
|
FILTER_SUB | final public static int FILTER_SUB(Code) | | |
FILTER_UP | final public static int FILTER_UP(Code) | | |
NO_ALPHA | final public static boolean NO_ALPHA(Code) | | Constant specifying that alpha channel should not be encoded.
|
bytePosmaxPos | protected int bytePosmaxPos(Code) | | |
bytesPerPixel | protected int bytesPerPixel(Code) | | |
compressionLevel | protected int compressionLevel(Code) | | |
crcValue | protected long crcValue(Code) | | |
encodeAlpha | protected boolean encodeAlpha(Code) | | |
filter | protected int filter(Code) | | |
hdrPosdataPosendPos | protected int hdrPosdataPosendPos(Code) | | |
leftBytes | protected byte[] leftBytes(Code) | | |
pngBytes | protected byte[] pngBytes(Code) | | |
priorRow | protected byte[] priorRow(Code) | | |
widthheight | protected int widthheight(Code) | | |
PngEncoder | public PngEncoder()(Code) | | Class constructor
|
PngEncoder | public PngEncoder(Image image)(Code) | | Class constructor specifying Image to encode, with no alpha channel encoding.
Parameters: image - A Java Image object which uses the DirectColorModel See Also: java.awt.Image |
PngEncoder | public PngEncoder(Image image, boolean encodeAlpha)(Code) | | Class constructor specifying Image to encode, and whether to encode alpha.
Parameters: image - A Java Image object which uses the DirectColorModel Parameters: encodeAlpha - Encode the alpha channel? false=no; true=yes See Also: java.awt.Image |
PngEncoder | public PngEncoder(Image image, boolean encodeAlpha, int whichFilter)(Code) | | Class constructor specifying Image to encode, whether to encode alpha, and filter to use.
Parameters: image - A Java Image object which uses the DirectColorModel Parameters: encodeAlpha - Encode the alpha channel? false=no; true=yes Parameters: whichFilter - 0=none, 1=sub, 2=up See Also: java.awt.Image |
PngEncoder | public PngEncoder(Image image, boolean encodeAlpha, int whichFilter, int compLevel)(Code) | | Class constructor specifying Image source to encode, whether to encode alpha, filter to use, and compression level.
Parameters: image - A Java Image object Parameters: encodeAlpha - Encode the alpha channel? false=no; true=yes Parameters: whichFilter - 0=none, 1=sub, 2=up Parameters: compLevel - 0..9 See Also: java.awt.Image |
filterSub | protected void filterSub(byte[] pixels, int startPos, int width)(Code) | | Perform "sub" filtering on the given row.
Uses temporary array leftBytes to store the original values
of the previous pixels. The array is 16 bytes long, which
will easily hold two-byte samples plus two-byte alpha.
Parameters: pixels - The array holding the scan lines being built Parameters: startPos - Starting position within pixels of bytes to be filtered. Parameters: width - Width of a scanline in pixels. |
filterUp | protected void filterUp(byte[] pixels, int startPos, int width)(Code) | | Perform "up" filtering on the given row.
Side effect: refills the prior row with current row
Parameters: pixels - The array holding the scan lines being built Parameters: startPos - Starting position within pixels of bytes to be filtered. Parameters: width - Width of a scanline in pixels. |
getCompressionLevel | public int getCompressionLevel()(Code) | | Retrieve compression level
int in range 0-9 |
getEncodeAlpha | public boolean getEncodeAlpha()(Code) | | Retrieve alpha encoding status.
boolean false=no, true=yes |
getFilter | public int getFilter()(Code) | | Retrieve filtering scheme
int (see constant list) |
pngEncode | public byte[] pngEncode(boolean encodeAlpha)(Code) | | Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not.
Parameters: encodeAlpha - boolean false=no alpha, true=encode alpha an array of bytes, or null if there was a problem |
pngEncode | public byte[] pngEncode()(Code) | | Creates an array of bytes that is the PNG equivalent of the current image.
Alpha encoding is determined by its setting in the constructor.
an array of bytes, or null if there was a problem |
resizeByteArray | protected byte[] resizeByteArray(byte[] array, int newLength)(Code) | | Increase or decrease the length of a byte array.
Parameters: array - The original array. Parameters: newLength - The length you wish the new array to have. Array of newly desired length. If shorter than theoriginal, the trailing elements are truncated. |
setCompressionLevel | public void setCompressionLevel(int level)(Code) | | Set the compression level to use
Parameters: level - 0 through 9 |
setEncodeAlpha | public void setEncodeAlpha(boolean encodeAlpha)(Code) | | Set the alpha encoding on or off.
Parameters: encodeAlpha - false=no, true=yes |
setFilter | public void setFilter(int whichFilter)(Code) | | Set the filter to use
Parameters: whichFilter - from constant list |
writeByte | protected int writeByte(int b, int offset)(Code) | | Write a single byte into the pngBytes array at a given position.
Parameters: b - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. |
writeBytes | protected int writeBytes(byte[] data, int offset)(Code) | | Write an array of bytes into the pngBytes array.
Note: This routine has the side effect of updating
maxPos, the largest element written in the array.
The array is resized by 1000 bytes or the length
of the data to be written, whichever is larger.
Parameters: data - The data to be written into pngBytes. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. |
writeBytes | protected int writeBytes(byte[] data, int nBytes, int offset)(Code) | | Write an array of bytes into the pngBytes array, specifying number of bytes to write.
Note: This routine has the side effect of updating
maxPos, the largest element written in the array.
The array is resized by 1000 bytes or the length
of the data to be written, whichever is larger.
Parameters: data - The data to be written into pngBytes. Parameters: nBytes - The number of bytes to be written. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. |
writeEnd | protected void writeEnd()(Code) | | Write a PNG "IEND" chunk into the pngBytes array.
|
writeHeader | protected void writeHeader()(Code) | | Write a PNG "IHDR" chunk into the pngBytes array.
|
writeImageData | protected boolean writeImageData()(Code) | | 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.
true if no errors; false if error grabbing pixels |
writeInt2 | protected int writeInt2(int n, int offset)(Code) | | Write a two-byte integer into the pngBytes array at a given position.
Parameters: n - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. |
writeInt4 | protected int writeInt4(int n, int offset)(Code) | | Write a four-byte integer into the pngBytes array at a given position.
Parameters: n - The integer to be written into pngBytes. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. |
writeString | protected int writeString(String s, int offset)(Code) | | Write a string into the pngBytes array at a given position.
This uses the getBytes method, so the encoding used will
be its default.
Parameters: s - The string to be written into pngBytes. Parameters: offset - The starting point to write to. The next place to be written to in the pngBytes array. See Also: java.lang.String.getBytes |
|
|