Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.ydp.jai
Class PNGImageEncoder  view PNGImageEncoder download PNGImageEncoder.java

java.lang.Object
  extended byorg.ydp.jai.ImageEncoderImpl
      extended byorg.ydp.jai.PNGImageEncoder
All Implemented Interfaces:
ImageEncoder

public class PNGImageEncoder
extends ImageEncoderImpl

An ImageEncoder for the PNG file format.


Field Summary
private  byte[] alphaPalette
           
private  int bitDepth
           
private  int bitShift
           
private  byte[] bluePalette
           
private  int bpp
           
private  int colorType
           
private  boolean compressGray
           
private  byte[] currRow
           
private  java.io.DataOutputStream dataOutput
           
private  byte[][] expandBits
           
private  byte[][] filteredRows
           
private  byte[] greenPalette
           
private  int height
           
private  java.awt.image.RenderedImage image
           
private  boolean interlace
           
private static byte[] magic
           
private  int numBands
           
private  PNGEncodeParam param
           
private static int PNG_COLOR_GRAY
           
private static int PNG_COLOR_GRAY_ALPHA
           
private static int PNG_COLOR_PALETTE
           
private static int PNG_COLOR_RGB
           
private static int PNG_COLOR_RGB_ALPHA
           
private  byte[] prevRow
           
private  byte[] redPalette
           
private  boolean skipAlpha
           
private static float[] srgbChroma
           
private  int width
           
 
Fields inherited from class org.ydp.jai.ImageEncoderImpl
output
 
Constructor Summary
PNGImageEncoder(java.io.OutputStream output, PNGEncodeParam param)
           
 
Method Summary
private static int clamp(int val, int maxValue)
           
private  PNGEncodeParam.Gray createGrayParam(byte[] redPalette, byte[] greenPalette, byte[] bluePalette, byte[] alphaPalette)
          Analyzes a set of palettes and determines if it can be expressed as a standard set of gray values, with zero or one values being fully transparent and the rest being fully opaque.
 void encode(java.awt.image.RenderedImage im)
          Encodes a RenderedImage and writes the output to the OutputStream associated with this ImageEncoder.
private  void encodePass(java.io.OutputStream os, java.awt.image.Raster ras, int xOffset, int yOffset, int xSkip, int ySkip)
           
private  void writeBKGD()
           
private  void writeCHRM()
           
private  void writeGAMA()
           
private  void writeHIST()
           
private  void writeICCP()
           
private  void writeIDAT()
           
private  void writeIEND()
           
private  void writeIHDR()
           
private  void writeMagic()
           
private  void writePHYS()
           
private  void writePLTE()
           
private  void writePrivateChunks()
           
private  void writeSBIT()
           
private  void writeSPLT()
           
private  void writeSRGB()
           
private  void writeTEXT()
           
private  void writeTIME()
           
private  void writeTRNS()
           
private  void writeZTXT()
           
 
Methods inherited from class org.ydp.jai.ImageEncoderImpl
encode, getOutputStream, getParam, setParam
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PNG_COLOR_GRAY

private static final int PNG_COLOR_GRAY
See Also:
Constant Field Values

PNG_COLOR_RGB

private static final int PNG_COLOR_RGB
See Also:
Constant Field Values

PNG_COLOR_PALETTE

private static final int PNG_COLOR_PALETTE
See Also:
Constant Field Values

PNG_COLOR_GRAY_ALPHA

private static final int PNG_COLOR_GRAY_ALPHA
See Also:
Constant Field Values

PNG_COLOR_RGB_ALPHA

private static final int PNG_COLOR_RGB_ALPHA
See Also:
Constant Field Values

magic

private static final byte[] magic

param

private PNGEncodeParam param

image

private java.awt.image.RenderedImage image

width

private int width

height

private int height

bitDepth

private int bitDepth

bitShift

private int bitShift

numBands

private int numBands

colorType

private int colorType

bpp

private int bpp

skipAlpha

private boolean skipAlpha

compressGray

private boolean compressGray

interlace

private boolean interlace

redPalette

private byte[] redPalette

greenPalette

private byte[] greenPalette

bluePalette

private byte[] bluePalette

alphaPalette

private byte[] alphaPalette

dataOutput

private java.io.DataOutputStream dataOutput

prevRow

private byte[] prevRow

currRow

private byte[] currRow

filteredRows

private byte[][] filteredRows

srgbChroma

private static final float[] srgbChroma

expandBits

private final byte[][] expandBits
Constructor Detail

PNGImageEncoder

public PNGImageEncoder(java.io.OutputStream output,
                       PNGEncodeParam param)
Method Detail

writeMagic

private void writeMagic()
                 throws java.io.IOException

writeIHDR

private void writeIHDR()
                throws java.io.IOException

clamp

private static int clamp(int val,
                         int maxValue)

encodePass

private void encodePass(java.io.OutputStream os,
                        java.awt.image.Raster ras,
                        int xOffset,
                        int yOffset,
                        int xSkip,
                        int ySkip)
                 throws java.io.IOException

writeIDAT

private void writeIDAT()
                throws java.io.IOException

writeIEND

private void writeIEND()
                throws java.io.IOException

writeCHRM

private void writeCHRM()
                throws java.io.IOException

writeGAMA

private void writeGAMA()
                throws java.io.IOException

writeICCP

private void writeICCP()
                throws java.io.IOException

writeSBIT

private void writeSBIT()
                throws java.io.IOException

writeSRGB

private void writeSRGB()
                throws java.io.IOException

writePLTE

private void writePLTE()
                throws java.io.IOException

writeBKGD

private void writeBKGD()
                throws java.io.IOException

writeHIST

private void writeHIST()
                throws java.io.IOException

writeTRNS

private void writeTRNS()
                throws java.io.IOException

writePHYS

private void writePHYS()
                throws java.io.IOException

writeSPLT

private void writeSPLT()
                throws java.io.IOException

writeTIME

private void writeTIME()
                throws java.io.IOException

writeTEXT

private void writeTEXT()
                throws java.io.IOException

writeZTXT

private void writeZTXT()
                throws java.io.IOException

writePrivateChunks

private void writePrivateChunks()
                         throws java.io.IOException

createGrayParam

private PNGEncodeParam.Gray createGrayParam(byte[] redPalette,
                                            byte[] greenPalette,
                                            byte[] bluePalette,
                                            byte[] alphaPalette)
Analyzes a set of palettes and determines if it can be expressed as a standard set of gray values, with zero or one values being fully transparent and the rest being fully opaque. If it is possible to express the data thusly, the method returns a suitable instance of PNGEncodeParam.Gray; otherwise it returns null.


encode

public void encode(java.awt.image.RenderedImage im)
            throws java.io.IOException
Description copied from class: ImageEncoderImpl
Encodes a RenderedImage and writes the output to the OutputStream associated with this ImageEncoder.

Specified by:
encode in interface ImageEncoder
Specified by:
encode in class ImageEncoderImpl