|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sixlegs.image.png.PngImage
For more information visit http://www.sixlegs.com/png.html
ImageProducer
Field Summary | |
static int |
COLOR_TYPE_GRAY
|
static int |
COLOR_TYPE_GRAY_ALPHA
|
static int |
COLOR_TYPE_PALETTE
|
static int |
COLOR_TYPE_RGB
|
static int |
COLOR_TYPE_RGB_ALPHA
|
static int |
COMPRESSION_TYPE_BASE
|
static int |
FILTER_TYPE_BASE
|
static int |
INTERLACE_TYPE_ADAM7
|
static int |
INTERLACE_TYPE_NONE
|
static int |
SRGB_ABSOLUTE_COLORIMETRIC
|
static int |
SRGB_PERCEPTUAL
|
static int |
SRGB_RELATIVE_COLORIMETRIC
|
static int |
SRGB_SATURATION_PRESERVING
|
static int |
UNIT_METER
|
static int |
UNIT_MICROMETER
|
static int |
UNIT_PIXEL
|
static int |
UNIT_RADIAN
|
static int |
UNIT_UNKNOWN
|
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. |
java.awt.Color |
getBackgroundColor()
Get a suggested background color (from the bKGD chunk). |
int |
getBitDepth()
Gets bit depth of image data. |
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. |
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. |
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 all known text chunks. |
int |
getWidth()
Gets width of image in pixels. |
boolean |
hasAlphaChannel()
Returns true if the image has an alpha channel. |
boolean |
hasErrors()
Checks if there were errors during image production. |
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. |
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. |
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 ImageConsumer interface. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int COLOR_TYPE_GRAY
public static final int COLOR_TYPE_GRAY_ALPHA
public static final int COLOR_TYPE_PALETTE
public static final int COLOR_TYPE_RGB
public static final int COLOR_TYPE_RGB_ALPHA
public static final int INTERLACE_TYPE_NONE
public static final int INTERLACE_TYPE_ADAM7
public static final int FILTER_TYPE_BASE
public static final int COMPRESSION_TYPE_BASE
public static final int UNIT_UNKNOWN
public static final int UNIT_METER
public static final int UNIT_PIXEL
public static final int UNIT_MICROMETER
public static final int UNIT_RADIAN
public static final int SRGB_PERCEPTUAL
public static final int SRGB_RELATIVE_COLORIMETRIC
public static final int SRGB_SATURATION_PRESERVING
public static final int SRGB_ABSOLUTE_COLORIMETRIC
Constructor Detail |
public PngImage(java.lang.String filename) throws java.io.IOException
filename
- full path to local PNG filepublic PngImage(java.net.URL url) throws java.io.IOException
PngImage
object from a URL.filename
- URL of PNG imagepublic PngImage(java.io.InputStream is)
PngImage
object from an input stream.
Buffer the stream for better performance.filename
- URL of PNG imagejava.io.BufferedInputStream
Method Detail |
public void addConsumer(java.awt.image.ImageConsumer ic)
ImageConsumer
to the list of consumers interested in
data for this image.ImageConsumer
public boolean isConsumer(java.awt.image.ImageConsumer ic)
ImageConsumer
is on the list of consumers currently
interested in data for this image.ImageConsumer
public void removeConsumer(java.awt.image.ImageConsumer ic)
ImageConsumer
from the list of consumers interested in
data for this image.ImageConsumer
public void startProduction(java.awt.image.ImageConsumer ic)
ImageConsumer
to the list of consumers interested in
data for this image, and immediately start delivery of the
image data through the ImageConsumer
interface.ImageConsumer
public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
ImageConsumer
one more time in top-down, left-right order. Currently ignored.startProduction(java.awt.image.ImageConsumer)
,
ImageConsumer
public static void setUserExponent(double exponent)
This method sets the user exponent for new PngImage
objects.
It is not possible to change the user exponent of an existing
PngImage
.
exponent
- desired user exponentpublic static void setDisplayExponent(double exponent)
This method sets the display exponent for new PngImage
objects.
It is not possible to change the display exponent of an existing
PngImage
.
exponent
- desired display exponentpublic boolean hasErrors()
ImageObserver
interface and the ERROR
flag is set.java.awt.image.ImageObserver
public java.util.Enumeration getErrors()
Enumeration
of all the errors that occurred during
image production. This includes any non-fatal errors.public static void setAllErrorsFatal(boolean allFatal)
public static void setProgressiveDisplay(boolean progressive)
PngImage
will call the imageComplete
method of its registered image consumers with a SINGLEFRAMEDONE
status after each pass. This, in turn, will trigger an imageUpdate
with the FRAMEBITS
flag set to watching ImageObservers
.
Progressive display is noticeably slower, but over slow connections this may not be an issue.
ImageConsumer
,
java.awt.image.ImageObserver
public java.awt.Color getBackgroundColor() throws java.io.IOException
getProperty(java.lang.String)
public int getWidth() throws java.io.IOException
getProperty(java.lang.String)
public int getHeight() throws java.io.IOException
getProperty(java.lang.String)
public int getBitDepth() throws java.io.IOException
getProperty(java.lang.String)
public int getInterlaceType() throws java.io.IOException
getProperty(java.lang.String)
public int getColorType() throws java.io.IOException
getProperty(java.lang.String)
public boolean hasAlphaChannel() throws java.io.IOException
getProperty(java.lang.String)
,
getColorType()
public boolean isGrayscale() throws java.io.IOException
getProperty(java.lang.String)
,
getColorType()
public java.lang.Object getProperty(java.lang.String name) throws java.io.IOException
null
.
The following properties are guaranteed to be defined:
Name | Type | Description |
"width" | Integer |
Image width in pixels |
"height" | Integer |
Image height in pixels |
"interlace type" | Integer |
See getInterlaceType |
"compression type" | Integer |
COMPRESSION_TYPE_BASE |
"filter type" | Integer |
FILTER_TYPE_BASE |
"color type" | Integer |
See getColorType |
"bit depth" | Integer |
1, 2, 4, 8, or 16 (1) |
"gamma" | Long |
File gamma * 100000 (2) |
"significant bits" | byte[] |
Significant bits per component: [r,g,b] [r,g,b,alpha] |
1 16-bit pixel components are reduced to 8 bits 2 Uses value from sRGB or gAMA chunks,
or default (45455 )3 For grayscale images, r == g == b |
The following properties are optional:
Name | Type | Description |
"palette" | int[][] |
Palette or suggested palette (PLTE chunk):[r,g,b][entry] |
"palette size" | Integer |
Size of palette, 1 - 256 |
"histogram" | int[] |
Palette entry usage frequency |
"background" | java.awt.Color |
Suggested background color |
"time" | java.util.Date |
Time of last image modification |
"pixel dimensions x" | Long |
Pixels per unit, X axis |
"pixel dimensions y" | Long |
Pixels per unit, Y axis |
"pixel dimensions unit" | Integer |
UNIT_UNKNOWN or UNIT_METER |
"image position x" | Integer |
Horizontal offset from left of page |
"image position y" | Integer |
Vertical offset from top of page |
"image position unit" | Integer |
UNIT_PIXEL or UNIT_MICROMETER |
"pixel scale x" | Double |
Pixel width, physical scale of subject |
"pixel scale y" | Double |
Pixel height, physical scale of subject |
"pixel scale unit" | Integer |
UNIT_METER or UNIT_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" | Integer |
SRGB_PERCEPTUAL or SRGB_RELATIVE_COLORIMETRIC or SRGB_SATURATION_PRESERVING or SRGB_ABSOLUTE_COLORIMETRIC |
"icc profile name" | String |
Internal ICC profile name |
"icc profile" | String |
Uncompressed ICC profile |
"pixel calibration purpose" | String |
Equation identifier |
"pixel calibration x0" | Integer |
Lower limit of original sample range |
"pixel calibration x1" | Integer |
Upper limit of original sample range |
"pixel calibration type" | Integer |
0 : Linear mapping1 : Base-e exponential mapping2 : Arbitrary-base exponential mapping3 : Hyperbolic mapping
|
"pixel calibration n" | Integer |
Number of parameters |
"pixel calibration unit" | String |
Symbol or description of unit |
"pixel calibration parameters" | double[] |
In addition, certain common (but still optional) text chunks
are available through the getProperty
interface:
Name | Type | Description |
"title" | TextChunk |
Short (one line) title or caption for image |
"author" | TextChunk |
Name of image's creator |
"description" | TextChunk |
Description of image (possibly long) |
"copyright" | TextChunk |
Copyright notice |
"creation time" | TextChunk |
Time of original image creation |
"software" | TextChunk |
Software used to create the image |
"disclaimer" | TextChunk |
Legal disclaimer |
"warning" | TextChunk |
Warning of nature of content |
"source" | TextChunk |
Device used to create the image |
"comment" | TextChunk |
Miscellaneous comment |
name
- a property namegetEverything()
,
getWidth()
,
getHeight()
,
getInterlaceType()
,
getColorType()
,
getTextChunk(java.lang.String)
,
getBackgroundColor()
public java.util.Enumeration getProperties() throws java.io.IOException
Enumeration
of the available properties.getProperty(java.lang.String)
public void getEverything()
getErrors
.
Note: The consumer/producer interface automatically
reads the entire PNG file. Do not use getEverything
unless you do not need the actual image data.
getTextChunk(java.lang.String)
,
getErrors()
public static void registerChunk(ChunkHandler handler, java.lang.String type)
ChunkHandler
to 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.
handler
- object to send chunk data totype
- chunk typeChunkHandler
public java.util.Enumeration getSuggestedPalettes() throws java.io.IOException
Enumeration
of the available suggested palette names.getSuggestedPalette(java.lang.String)
public int[][] getSuggestedPalette(java.lang.String name) throws java.io.IOException
name
- the name of the suggested palette[r,g,b,alpha,freq][entry]
getSuggestedPalette(java.lang.String)
public TextChunk getTextChunk(java.lang.String key) throws java.io.IOException
getEverything
).key
- the key of the desired chunkgetTextChunks()
,
getEverything()
,
getProperty(java.lang.String)
public java.util.Enumeration getTextChunks() throws java.io.IOException
getEverything
).Enumeration
of the keys of all known text chunks.getTextChunk(java.lang.String)
,
getEverything()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |