|
|||||||||
| Home >> All >> com >> sixlegs >> image >> [ png overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.sixlegs.image.png
Class PngImage

java.lang.Objectcom.sixlegs.image.png.PngImage
- All Implemented Interfaces:
- java.awt.image.ImageProducer
- public final class PngImage
- extends java.lang.Object
- implements java.awt.image.ImageProducer
- extends java.lang.Object
For more information visit http://www.sixlegs.com/
- Version:
- 1.2.3 May 14, 2002
| Nested Class Summary | |
(package private) class |
PngImage.Data
|
| Constructor Summary | |
PngImage(java.io.InputStream is)
Constructs a PngImage object from an input stream. |
|
PngImage(java.lang.String filename)
Constructs a PngImage object from a local PNG file. |
|
PngImage(java.net.URL url)
Constructs a PngImage object from a URL. |
|
| Method Summary | |
void |
addConsumer(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in
data for this image. |
(package private) void |
addError(java.lang.Exception e)
|
(package private) void |
fillGammaTable()
|
private void |
firstProduction(java.awt.image.ImageConsumer[] ics)
|
private void |
flush()
|
java.awt.Color |
getBackgroundColor()
Get a suggested background color (from the bKGD chunk). |
int |
getBitDepth()
Gets bit depth of image data. |
(package private) Chunk |
getChunk(int type)
|
int |
getColorType()
Gets the alpha and color properties of an image. |
java.util.Enumeration |
getErrors()
Returns an Enumeration of all the errors that occurred during
image production. |
void |
getEverything()
Ensures that the entire PNG file has been read. |
java.util.Enumeration |
getGifExtensions()
Returns all known GIF Application Extensions. |
int |
getHeight()
Gets height of image in pixels. |
int |
getInterlaceType()
Gets the interlacing method used by this image. |
java.util.Enumeration |
getProperties()
Returns an Enumeration of the available properties. |
java.lang.Object |
getProperty(java.lang.String name)
Gets a property of this image by name. |
(package private) static Chunk |
getRegisteredChunk(int type)
|
int[][] |
getSuggestedPalette(java.lang.String name)
Returns the suggested palette (sPLT chunk) specified by the palette name. |
java.util.Enumeration |
getSuggestedPalettes()
Returns an Enumeration of the available suggested palette names. |
TextChunk |
getTextChunk(java.lang.String key)
Returns the specified text chunk. |
java.util.Enumeration |
getTextChunks()
Returns the keys of all known text chunks. |
int |
getWidth()
Gets width of image in pixels. |
boolean |
hasAlphaChannel()
Returns true if the image has an alpha channel. |
boolean |
hasChunk(java.lang.String type)
|
boolean |
hasErrors()
Checks if there were errors during image production. |
boolean |
hasFatalError()
|
private void |
init(java.io.InputStream in_raw)
|
boolean |
isConsumer(java.awt.image.ImageConsumer ic)
Determine if an ImageConsumer is on the list of consumers currently
interested in data for this image. |
boolean |
isGrayscale()
Returns true if the image is grayscale. |
boolean |
isIndexedColor()
Returns true if the image is paletted. |
private void |
produceHelper(java.awt.image.ImageConsumer[] ics)
|
private void |
produceInterlaced(java.awt.image.ImageConsumer[] ics,
PixelInputStream pis)
|
private void |
produceNonInterlaced(java.awt.image.ImageConsumer[] ics,
PixelInputStream pis)
|
(package private) void |
putChunk(int type,
Chunk c)
|
private void |
readToData()
|
private static void |
registerChunk(Chunk proto)
|
static void |
registerChunk(ChunkHandler handler,
java.lang.String type)
Register a ChunkHandler to handle a user defined
chunk type. |
void |
removeConsumer(java.awt.image.ImageConsumer ic)
Remove an ImageConsumer from the list of consumers interested in
data for this image. |
void |
requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Requests delivery of image data to the specified ImageConsumer
one more time in top-down, left-right order. |
static void |
setAllErrorsFatal(boolean allFatal)
Specifies whether all errors will abort the image production. |
static void |
setDisplayExponent(double exponent)
Sets the default display exponent. |
void |
setFlushAfterNextProduction(boolean useFlush)
Readies this PngImage to be flushed after the next image production, to free memory (default false). |
private void |
setHints(java.awt.image.ImageConsumer[] ics)
|
static void |
setProgressiveDisplay(boolean progressive)
Interlaced images can either be displayed when completely read (default) or progressively. |
static void |
setUserExponent(double exponent)
Sets the default desired final user exponent. |
void |
startProduction(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in
data for this image, and immediately start delivery of the
image data through the consumer/producer interface. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
allFatal
static boolean allFatal
BUFFER_SIZE
static final int BUFFER_SIZE
- See Also:
- Constant Field Values
progressive
private static boolean progressive
prototypes
private static java.util.Hashtable prototypes
ASCII_ENCODING
static final java.lang.String ASCII_ENCODING
- See Also:
- Constant Field Values
LATIN1_ENCODING
static final java.lang.String LATIN1_ENCODING
- See Also:
- Constant Field Values
UTF8_ENCODING
static final java.lang.String UTF8_ENCODING
- See Also:
- Constant Field Values
DEFAULT_GAMMA
static final long DEFAULT_GAMMA
- See Also:
- Constant Field Values
DISPLAY_EXPONENT
private static double DISPLAY_EXPONENT
USER_EXPONENT
private static double USER_EXPONENT
data
PngImage.Data data
errorList
private java.util.Vector errorList
COLOR_TYPE_GRAY
public static final int COLOR_TYPE_GRAY
- See Also:
- Constant Field Values
COLOR_TYPE_GRAY_ALPHA
public static final int COLOR_TYPE_GRAY_ALPHA
- See Also:
- Constant Field Values
COLOR_TYPE_PALETTE
public static final int COLOR_TYPE_PALETTE
- See Also:
- Constant Field Values
COLOR_TYPE_RGB
public static final int COLOR_TYPE_RGB
- See Also:
- Constant Field Values
COLOR_TYPE_RGB_ALPHA
public static final int COLOR_TYPE_RGB_ALPHA
- See Also:
- Constant Field Values
INTERLACE_TYPE_NONE
public static final int INTERLACE_TYPE_NONE
- See Also:
- Constant Field Values
INTERLACE_TYPE_ADAM7
public static final int INTERLACE_TYPE_ADAM7
- See Also:
- Constant Field Values
FILTER_TYPE_BASE
public static final int FILTER_TYPE_BASE
- See Also:
- Constant Field Values
FILTER_TYPE_INTRAPIXEL
public static final int FILTER_TYPE_INTRAPIXEL
- See Also:
- Constant Field Values
COMPRESSION_TYPE_BASE
public static final int COMPRESSION_TYPE_BASE
- See Also:
- Constant Field Values
UNIT_UNKNOWN
public static final int UNIT_UNKNOWN
- See Also:
- Constant Field Values
UNIT_METER
public static final int UNIT_METER
- See Also:
- Constant Field Values
UNIT_PIXEL
public static final int UNIT_PIXEL
- See Also:
- Constant Field Values
UNIT_MICROMETER
public static final int UNIT_MICROMETER
- See Also:
- Constant Field Values
UNIT_RADIAN
public static final int UNIT_RADIAN
- See Also:
- Constant Field Values
SRGB_PERCEPTUAL
public static final int SRGB_PERCEPTUAL
- See Also:
- Constant Field Values
SRGB_RELATIVE_COLORIMETRIC
public static final int SRGB_RELATIVE_COLORIMETRIC
- See Also:
- Constant Field Values
SRGB_SATURATION_PRESERVING
public static final int SRGB_SATURATION_PRESERVING
- See Also:
- Constant Field Values
SRGB_ABSOLUTE_COLORIMETRIC
public static final int SRGB_ABSOLUTE_COLORIMETRIC
- See Also:
- Constant Field Values
| Constructor Detail |
PngImage
public PngImage(java.lang.String filename) throws java.io.IOException
- Constructs a PngImage object from a local PNG file.
PngImage
public PngImage(java.net.URL url) throws java.io.IOException
- Constructs a
PngImageobject from a URL.
PngImage
public PngImage(java.io.InputStream is)
- Constructs a
PngImageobject from an input stream. Buffer the stream for better performance.
| Method Detail |
addConsumer
public void addConsumer(java.awt.image.ImageConsumer ic)
- Adds an
ImageConsumerto the list of consumers interested in data for this image.- Specified by:
addConsumerin interfacejava.awt.image.ImageProducer
isConsumer
public boolean isConsumer(java.awt.image.ImageConsumer ic)
- Determine if an
ImageConsumeris on the list of consumers currently interested in data for this image.- Specified by:
isConsumerin interfacejava.awt.image.ImageProducer
removeConsumer
public void removeConsumer(java.awt.image.ImageConsumer ic)
- Remove an
ImageConsumerfrom the list of consumers interested in data for this image.- Specified by:
removeConsumerin interfacejava.awt.image.ImageProducer
startProduction
public void startProduction(java.awt.image.ImageConsumer ic)
- Adds an
ImageConsumerto the list of consumers interested in data for this image, and immediately start delivery of the image data through the consumer/producer interface.- Specified by:
startProductionin interfacejava.awt.image.ImageProducer
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
- Requests delivery of image data to the specified
ImageConsumerone more time in top-down, left-right order.- Specified by:
requestTopDownLeftRightResendin interfacejava.awt.image.ImageProducer
setUserExponent
public static void setUserExponent(double exponent)
- Sets the default desired final user exponent. Ideal setting
depends on user viewing conditions. The default value is 1.0.
Set greater than 1.0 to darken the mid-level tones, or less than
1.0 to lighten them.
This method sets the user exponent for new
PngImageobjects. It is not possible to change the user exponent of an existingPngImage.
setDisplayExponent
public static void setDisplayExponent(double exponent)
- Sets the default display exponent. Depends on monitor and gamma lookup
table settings (if any). Default value is 2.2, which should
work well with most PC displays. If the operating system has
a gamma lookup table (Macintosh) the display exponent should be lower.
This method sets the display exponent for new
PngImageobjects. It is not possible to change the display exponent of an existingPngImage.
hasErrors
public boolean hasErrors()
- Checks if there were errors during image production.
A good time to check this is when you implement the
ImageObserverinterface and theERRORflag is set.
hasFatalError
public boolean hasFatalError()
getErrors
public java.util.Enumeration getErrors()
- Returns an
Enumerationof all the errors that occurred during image production. This includes any non-fatal errors.
setAllErrorsFatal
public static void setAllErrorsFatal(boolean allFatal)
- Specifies whether all errors will abort the image production.
Normally, a value error in a non-critical chunk causes the
PNG loader to simply skip the offending chunk.
setProgressiveDisplay
public static void setProgressiveDisplay(boolean progressive)
- Interlaced images can either be displayed when completely
read (default) or progressively. When progressive display is
enabled, a
PngImagewill call theimageCompletemethod of its registered image consumers with aSINGLEFRAMEDONEstatus after each pass. This, in turn, will trigger animageUpdatewith theFRAMEBITSflag set to watchingImageObservers.Note: Images are only delivered progressively on the first production of the image data. Subsequent requests for the (cached) image data will send the image as a complete single frame.
getBackgroundColor
public java.awt.Color getBackgroundColor() throws java.io.IOException
- Get a suggested background color (from the bKGD chunk).
getWidth
public int getWidth()
throws java.io.IOException
- Gets width of image in pixels.
getHeight
public int getHeight()
throws java.io.IOException
- Gets height of image in pixels.
getBitDepth
public int getBitDepth()
throws java.io.IOException
- Gets bit depth of image data.
getInterlaceType
public int getInterlaceType()
throws java.io.IOException
- Gets the interlacing method used by this image.
getColorType
public int getColorType()
throws java.io.IOException
- Gets the alpha and color properties of an image.
An image can either be grayscale, grayscale with alpha channel,
RGB, RGB with alpha channel, or paletted.
hasAlphaChannel
public boolean hasAlphaChannel()
throws java.io.IOException
- Returns true if the image has an alpha channel.
isGrayscale
public boolean isGrayscale()
throws java.io.IOException
- Returns true if the image is grayscale.
isIndexedColor
public boolean isIndexedColor()
throws java.io.IOException
- Returns true if the image is paletted.
getProperty
public java.lang.Object getProperty(java.lang.String name) throws java.io.IOException
- Gets a property of this image by name. If a property is not
defined for a particular image, this method returns
null.Note: This method will only read up to the beginning of the image data unless the image data has already been read, either through the consumer/producer interface or by calling
getEverything.The following properties are guaranteed to be defined:
Name Type Description "width" IntegerImage width in pixels "height" IntegerImage height in pixels "interlace type" IntegerSee getInterlaceType "compression type" IntegerCOMPRESSION_TYPE_BASE"filter type" IntegerFILTER_TYPE_BASE"color type" IntegerSee getColorType "bit depth" Integer1, 2, 4, 8, or 16 (1) "gamma" LongFile gamma * 100000 (2) "significant bits" byte[]Significant bits per component: or[r,g,b] (3)[r,g,b,alpha]1 16-bit pixel components are reduced to 8 bits
2 Uses value fromsRGBorgAMAchunks, or default (45455)
3 For grayscale images,r == g == bThe following properties are optional:
Name Type Description "palette" int[][]Palette or suggested palette (PLTE chunk):
or[r,g,b][entry][r,g,b][entry]"palette size" IntegerSize of palette, 1 - 256 "histogram" int[]Palette entry usage frequency "background" java.awt.ColorSuggested background color "background low bytes" java.awt.ColorThe low (least significant) bytes of a 16-bit background color "background index" IntegerThe palette index of the suggested background color "time" java.util.DateTime of last image modification "pixel dimensions x" LongPixels per unit, X axis "pixel dimensions y" LongPixels per unit, Y axis "pixel dimensions unit" IntegerUNIT_UNKNOWNorUNIT_METER"image position x" IntegerHorizontal offset from left of page "image position y" IntegerVertical offset from top of page "image position unit" IntegerUNIT_PIXELorUNIT_MICROMETER"pixel scale x" DoublePixel width, physical scale of subject "pixel scale y" DoublePixel height, physical scale of subject "pixel scale unit" IntegerUNIT_METERorUNIT_RADIAN"chromaticity xy" long[][]CIE x,y chromaticities * 100000: [white,r,g,b][x,y]"chromaticity xyz" double[][]CIE XYZ chromaticities: [white,r,g,b][X,Y,Z]"srgb rendering intent" IntegerSRGB_PERCEPTUALor
SRGB_RELATIVE_COLORIMETRICor
SRGB_SATURATION_PRESERVINGor
SRGB_ABSOLUTE_COLORIMETRIC"icc profile name" StringInternal ICC profile name "icc profile" StringUncompressed ICC profile "pixel calibration purpose" StringEquation identifier "pixel calibration x0" IntegerLower limit of original sample range "pixel calibration x1" IntegerUpper limit of original sample range "pixel calibration type" Integer0: Linear mapping
1: Base-e exponential mapping
2: Arbitrary-base exponential mapping
3: Hyperbolic mapping"pixel calibration n" IntegerNumber of parameters "pixel calibration unit" StringSymbol or description of unit "pixel calibration parameters" double[]"gif disposal method" IntegerSee GIF89a Graphic Control Extension specification "gif user input flag" IntegerSee GIF89a Graphic Control Extension specification "gif delay time" IntegerSee GIF89a Graphic Control Extension specification "transparency" java.awt.ColorTransparent color (4) "transparency low bytes" java.awt.ColorThe low (least significant) bytes of a 16-bit transparency color (4) "transparency size" IntegerThe number of palette entries with transparency information (5) 4 Grayscale or truecolor images only
5 Indexed-color images onlyIn addition, certain common (but still optional) text chunks are available through the
getPropertyinterface:Name Type Description "title" TextChunkShort (one line) title or caption for image "author" TextChunkName of image's creator "description" TextChunkDescription of image (possibly long) "copyright" TextChunkCopyright notice "creation time" TextChunkTime of original image creation "software" TextChunkSoftware used to create the image "disclaimer" TextChunkLegal disclaimer "warning" TextChunkWarning of nature of content "source" TextChunkDevice used to create the image "comment" TextChunkMiscellaneous comment
getProperties
public java.util.Enumeration getProperties() throws java.io.IOException
- Returns an
Enumerationof the available properties.
getEverything
public void getEverything()
- Ensures that the entire PNG file has been read. No exceptions
are throws; errors are available by calling
getErrors.Note: The consumer/producer interface automatically reads the entire PNG file. It usually is not necessary to call
getEverythingunless you do not need the actual image data.
hasChunk
public boolean hasChunk(java.lang.String type)
registerChunk
public static void registerChunk(ChunkHandler handler, java.lang.String type) throws PngException
- Register a
ChunkHandlerto handle a user defined chunk type.The chunk type must be four characters, ancillary (lowercase first letter), and may not already be registered. You may register one of the supported ancillary chunk types (except
tRNS) to override the standard behavior.
getSuggestedPalettes
public java.util.Enumeration getSuggestedPalettes() throws java.io.IOException
- Returns an
Enumerationof the available suggested palette names.
getSuggestedPalette
public int[][] getSuggestedPalette(java.lang.String name) throws java.io.IOException
- Returns the suggested palette (sPLT chunk) specified by the
palette name.
getTextChunk
public TextChunk getTextChunk(java.lang.String key) throws java.io.IOException
- Returns the specified text chunk.
Note: Text chunks may appear anywhere in the file. This method will only read up to the beginning of the image data unless the image data has already been read, either through the consumer/producer interface or by calling
getEverything.
getTextChunks
public java.util.Enumeration getTextChunks() throws java.io.IOException
- Returns the keys of all known text chunks.
Note: Text chunks may appear anywhere in the file. This method will only read up to the beginning of the image data unless the image data has already been read, either through the consumer/producer interface or by calling
getEverything.
getGifExtensions
public java.util.Enumeration getGifExtensions() throws java.io.IOException
- Returns all known GIF Application Extensions.
Note: GIF Application Extensions may appear anywhere in the file. This method will only read up to the beginning of the image data unless the image data has already been read, either through the consumer/producer interface or by calling
getEverything.
setFlushAfterNextProduction
public void setFlushAfterNextProduction(boolean useFlush)
- Readies this PngImage to be flushed after the next image
production, to free memory (default false).
After flushing, you may only call the
getErrorsandhasErrorsmethods on this object. The pixel data will no longer be available through the consumer/producer interface.Note: Using a PixelGrabber object on an Image produced by this PngImage object will ask for a second production of the pixel data, which will fail if the object has been flushed.
flush
private void flush()
init
private void init(java.io.InputStream in_raw)
readToData
private void readToData()
throws java.io.IOException
registerChunk
private static void registerChunk(Chunk proto)
getRegisteredChunk
static Chunk getRegisteredChunk(int type)
getChunk
Chunk getChunk(int type)
putChunk
void putChunk(int type,
Chunk c)
addError
void addError(java.lang.Exception e)
fillGammaTable
void fillGammaTable()
produceHelper
private void produceHelper(java.awt.image.ImageConsumer[] ics)
firstProduction
private void firstProduction(java.awt.image.ImageConsumer[] ics) throws java.io.IOException
setHints
private void setHints(java.awt.image.ImageConsumer[] ics)
produceNonInterlaced
private void produceNonInterlaced(java.awt.image.ImageConsumer[] ics, PixelInputStream pis) throws java.io.IOException
produceInterlaced
private void produceInterlaced(java.awt.image.ImageConsumer[] ics, PixelInputStream pis) throws java.io.IOException
|
|||||||||
| Home >> All >> com >> sixlegs >> image >> [ png overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.sixlegs.image.png.PngImage