Save This Page
Home » jcommon-1.0.13 » com.keypoint » [javadoc | source]
com.keypoint
public class: PngEncoderB [javadoc | source]
java.lang.Object
   com.keypoint.PngEncoder
      com.keypoint.PngEncoderB
PngEncoderB takes a Java BufferedImage object and creates a byte string which can be saved as a PNG file. The encoder will accept BufferedImages with eight-bit samples or 4-byte ARGB samples. There is also code to handle 4-byte samples returned as one int per pixel, but that has not been tested. Thanks to Jay Denny at KeyPoint Software http://www.keypoint.com/ who let me develop this code on company time. You may contact me with (probably very-much-needed) improvements, comments, and bug fixes at: david@catcode.com This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA A copy of the GNU LGPL may be found at http://www.gnu.org/copyleft/lesser.html,
Field Summary
protected  BufferedImage image     
protected  WritableRaster wRaster     
protected  int tType     
protected  boolean grayscale     
Fields inherited from com.keypoint.PngEncoder:
ENCODE_ALPHA,  NO_ALPHA,  FILTER_NONE,  FILTER_SUB,  FILTER_UP,  FILTER_LAST,  IHDR,  IDAT,  IEND,  PHYS,  pngBytes,  priorRow,  leftBytes,  image,  width,  height,  bytePos,  maxPos,  crc,  crcValue,  encodeAlpha,  filter,  bytesPerPixel,  compressionLevel
Constructor:
 public PngEncoderB() 
 public PngEncoderB(BufferedImage image) 
    Class constructor specifying BufferedImage to encode, with no alpha channel encoding.
    Parameters:
    image - A Java BufferedImage object
 public PngEncoderB(BufferedImage image,
    boolean encodeAlpha) 
    Class constructor specifying BufferedImage to encode, and whether to encode alpha.
    Parameters:
    image - A Java BufferedImage object
    encodeAlpha - Encode the alpha channel? false=no; true=yes
 public PngEncoderB(BufferedImage image,
    boolean encodeAlpha,
    int whichFilter) 
    Class constructor specifying BufferedImage to encode, whether to encode alpha, and filter to use.
    Parameters:
    image - A Java BufferedImage object
    encodeAlpha - Encode the alpha channel? false=no; true=yes
    whichFilter - 0=none, 1=sub, 2=up
 public PngEncoderB(BufferedImage image,
    boolean encodeAlpha,
    boolean grayscale,
    int whichFilter,
    int compLevel) 
    Class constructor specifying BufferedImage source to encode, whether to encode alpha, filter to use, and compression level
    Parameters:
    image - A Java BufferedImage object
    encodeAlpha - Encode the alpha channel? false=no; true=yes
    grayscale - output with grayscale? false=no; true=yes
    whichFilter - 0=none, 1=sub, 2=up
    compLevel - 0..9
Method from com.keypoint.PngEncoderB Summary:
establishStorageInfo,   pngEncode,   pngEncode,   setImage,   writeHeader,   writeImageData,   writePalette,   writebKGD
Methods from com.keypoint.PngEncoder:
filterSub,   filterUp,   getCompressionLevel,   getEncodeAlpha,   getFilter,   getImage,   getXDpi,   getYDpi,   pngEncode,   pngEncode,   resizeByteArray,   setCompressionLevel,   setDpi,   setEncodeAlpha,   setFilter,   setImage,   setXDpi,   setYDpi,   writeByte,   writeBytes,   writeBytes,   writeEnd,   writeHeader,   writeImageData,   writeInt2,   writeInt4,   writeResolution
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.keypoint.PngEncoderB Detail:
 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.
 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.
 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  void setImage(BufferedImage image) 
    Set the BufferedImage to be encoded
 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. In order to conserve memory, this method grabs as many rows as will fit into 32K bytes, or the whole image; whichever is less.
 protected  void writePalette(IndexColorModel icm) 
 protected  void writebKGD() 
    Write a PNG "bKGD" chunk with the white color