All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.keypoint.PngEncoder.html Maven / Gradle / Ivy

The newest version!






: Class  PngEncoder








com.keypoint
Class PngEncoder

java.lang.Object
  |
  +--com.keypoint.PngEncoder

public class PngEncoder
extends java.lang.Object


Field Summary
protected  int bytePos
           
protected  int bytesPerPixel
           
protected  int compressionLevel
           
protected  java.util.zip.CRC32 crc
           
protected  long crcValue
           
protected  int dataPos
           
static boolean ENCODE_ALPHA
          Constant specifying that alpha channel should be encoded.
protected  boolean encodeAlpha
           
protected  int endPos
           
protected  int filter
           
static int FILTER_LAST
           
static int FILTER_NONE
          Constants for filters
static int FILTER_SUB
           
static int FILTER_UP
           
protected  int hdrPos
           
protected  int height
           
protected  java.awt.Image image
           
protected  byte[] leftBytes
           
protected  int maxPos
           
static boolean NO_ALPHA
          Constant specifying that alpha channel should not be encoded.
protected  byte[] pngBytes
           
protected  byte[] priorRow
           
protected  int width
           
 
Constructor Summary
PngEncoder()
          Class constructor
PngEncoder(java.awt.Image image)
          Class constructor specifying Image source to encode, with no alpha channel encoding.
PngEncoder(java.awt.Image image, boolean encodeAlpha)
          Class constructor specifying Image source to encode, and whether to encode alpha or not
PngEncoder(java.awt.Image image, boolean encodeAlpha, int which_filter)
          Class constructor specifying Image source to encode, whether to encode alpha or not, and which filter to use
PngEncoder(java.awt.Image image, boolean encodeAlpha, int which_filter, int comp_level)
          Class constructor specifying Image source to encode, whether to encode alpha or not, which filter to use, and compression level.
 
Method Summary
 int getCompressionLevel()
          Retrieve compression level
 boolean getEncodeAlpha()
          Retrieve alpha encoding status.
 int getFilter()
          Retrieve filtering scheme
 byte[] pngEncode()
          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.
protected  byte[] resizeByteArray(byte[] array, int newLength)
          Increase or decrease the length of a byte array.
 void setCompressionLevel(int level)
          Set the compression level to use
 void setEncodeAlpha(boolean encodeAlpha)
          Set the alpha encoding on or off.
 void setFilter(int which_filter)
          Set the filter to use
 void setImage(java.awt.Image image)
          Set the image to be encoded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODE_ALPHA

public static final boolean ENCODE_ALPHA
Constant specifying that alpha channel should be encoded.

NO_ALPHA

public static final boolean NO_ALPHA
Constant specifying that alpha channel should not be encoded.

FILTER_NONE

public static final int FILTER_NONE
Constants for filters

FILTER_SUB

public static final int FILTER_SUB

FILTER_UP

public static final int FILTER_UP

FILTER_LAST

public static final int FILTER_LAST

pngBytes

protected byte[] pngBytes

priorRow

protected byte[] priorRow

leftBytes

protected byte[] leftBytes

image

protected java.awt.Image image

width

protected int width

height

protected int height

bytePos

protected int bytePos

maxPos

protected int maxPos

hdrPos

protected int hdrPos

dataPos

protected int dataPos

endPos

protected int endPos

crc

protected java.util.zip.CRC32 crc

crcValue

protected long crcValue

encodeAlpha

protected boolean encodeAlpha

filter

protected int filter

bytesPerPixel

protected int bytesPerPixel

compressionLevel

protected int compressionLevel
Constructor Detail

PngEncoder

public PngEncoder()
Class constructor

PngEncoder

public PngEncoder(java.awt.Image image)
Class constructor specifying Image source to encode, with no alpha channel encoding.
Parameters:
image - A Java Image object which uses the DirectColorModel
See Also:
Image, java.awt.image.DirectColorModel

PngEncoder

public PngEncoder(java.awt.Image image,
                  boolean encodeAlpha)
Class constructor specifying Image source to encode, and whether to encode alpha or not
Parameters:
image - A Java Image object which uses the DirectColorModel
encodeAlpha - Encode the alpha channel? false=no; true=yes
See Also:
Image, java.awt.image.DirectColorModel

PngEncoder

public PngEncoder(java.awt.Image image,
                  boolean encodeAlpha,
                  int which_filter)
Class constructor specifying Image source to encode, whether to encode alpha or not, and which filter to use
Parameters:
image - A Java Image object which uses the DirectColorModel
encodeAlpha - Encode the alpha channel? false=no; true=yes
which_filter - 0=none, 1=sub, 2=up
See Also:
Image, java.awt.image.DirectColorModel

PngEncoder

public PngEncoder(java.awt.Image image,
                  boolean encodeAlpha,
                  int which_filter,
                  int comp_level)
Class constructor specifying Image source to encode, whether to encode alpha or not, which filter to use, and compression level.
Parameters:
image - A Java Image object which uses the DirectColorModel
encodeAlpha - Encode the alpha channel? false=no; true=yes
which_filter - 0=none, 1=sub, 2=up
comp_level - 0..9
See Also:
Image, java.awt.image.DirectColorModel
Method Detail

setImage

public void setImage(java.awt.Image image)
Set the image to be encoded
Parameters:
image - A Java Image object which uses the DirectColorModel
See Also:
Image, java.awt.image.DirectColorModel

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.
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.
Returns:
an array of bytes, or null if there was a problem

setEncodeAlpha

public void setEncodeAlpha(boolean encodeAlpha)
Set the alpha encoding on or off.
Parameters:
encodeAlpha - false=no, true=yes

getEncodeAlpha

public boolean getEncodeAlpha()
Retrieve alpha encoding status.
Returns:
boolean false=no, true=yes

setFilter

public void setFilter(int which_filter)
Set the filter to use
Parameters:
which_filter - from constant list

getFilter

public int getFilter()
Retrieve filtering scheme
Returns:
int (see constant list)

setCompressionLevel

public void setCompressionLevel(int level)
Set the compression level to use
Parameters:
level - 0 through 9

getCompressionLevel

public int getCompressionLevel()
Retrieve compression level
Returns:
int in range 0-9

resizeByteArray

protected byte[] resizeByteArray(byte[] array,
                                 int newLength)
Increase or decrease the length of a byte array.
Parameters:
array - The original array.
newLength - The length you wish the new array to have.
Returns:
Array of newly desired length. If shorter than the original, the trailing elements are truncated.






© 2015 - 2024 Weber Informatics LLC | Privacy Policy