|
mxGraph 1.10.0.5 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mxgraph.util.png.mxPngEncodeParam
public abstract class mxPngEncodeParam
An instance of ImageEncodeParam
for encoding images in
the PNG format.
This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.
Nested Class Summary | |
---|---|
static class |
mxPngEncodeParam.Gray
|
static class |
mxPngEncodeParam.Palette
|
static class |
mxPngEncodeParam.RGB
|
Field Summary | |
---|---|
protected int |
bitDepth
|
protected boolean |
bitDepthSet
|
static int |
INTENT_ABSOLUTE
Constant for use with the sRGB chunk. |
static int |
INTENT_PERCEPTUAL
Constant for use with the sRGB chunk. |
static int |
INTENT_RELATIVE
Constant for use with the sRGB chunk. |
static int |
INTENT_SATURATION
Constant for use with the sRGB chunk. |
static int |
PNG_FILTER_AVERAGE
Constant for use in filtering. |
static int |
PNG_FILTER_NONE
Constant for use in filtering. |
static int |
PNG_FILTER_PAETH
Constant for use in filtering. |
static int |
PNG_FILTER_SUB
Constant for use in filtering. |
static int |
PNG_FILTER_UP
Constant for use in filtering. |
Constructor Summary | |
---|---|
mxPngEncodeParam()
|
Method Summary | |
---|---|
void |
addPrivateChunk(String type,
byte[] data)
Adds a private chunk, in binary form, to the list of chunks to be stored with this image. |
int |
filterRow(byte[] currRow,
byte[] prevRow,
byte[][] scratchRows,
int bytesPerRow,
int bytesPerPixel)
Performs filtering on a row of an image. |
int |
getBitDepth()
Returns the desired bit depth for a grayscale image. |
float[] |
getChromaticity()
Returns the white point and primary chromaticities in CIE (x, y) space. |
String[] |
getCompressedText()
Returns the text strings to be stored in compressed form with this image as an array of String s. |
static mxPngEncodeParam |
getDefaultEncodeParam(RenderedImage im)
Returns an instance of PNGEncodeParam.Palette ,
PNGEncodeParam.Gray , or
PNGEncodeParam.RGB appropriate for encoding
the given image. |
float |
getGamma()
Returns the file gamma value for the image. |
byte[] |
getICCProfileData()
Returns the ICC profile data to be stored with this image. |
boolean |
getInterlacing()
Returns true if Adam7 interlacing will be used. |
Date |
getModificationTime()
Returns the modification time to be stored with this image. |
int |
getNumPrivateChunks()
Returns the number of private chunks to be written to the output file. |
int[] |
getPaletteHistogram()
Returns the palette histogram to be stored with this image. |
int[] |
getPhysicalDimension()
Returns the physical dimension information to be stored with this image. |
byte[] |
getPrivateChunkData(int index)
Returns the data associated of the private chunk at a given index, as an array of byte s. |
String |
getPrivateChunkType(int index)
Returns the type of the private chunk at a given index, as a 4-character String . |
int[] |
getSignificantBits()
Returns the number of significant bits for each band of the image. |
int |
getSRGBIntent()
Returns the sRGB rendering intent to be stored with this image. |
String[] |
getText()
Returns the text strings to be stored in uncompressed form with this image as an array of String s. |
boolean |
isBackgroundSet()
Returns true if a 'bKGD' chunk will be output. |
boolean |
isChromaticitySet()
Returns true if a 'cHRM' chunk will be output. |
boolean |
isCompressedTextSet()
Returns true if a 'zTXT' chunk will be output. |
boolean |
isGammaSet()
Returns true if a 'gAMA' chunk will be output. |
boolean |
isICCProfileDataSet()
Returns true if a 'iCCP' chunk will be output. |
boolean |
isModificationTimeSet()
Returns true if a 'tIME' chunk will be output. |
boolean |
isPaletteHistogramSet()
Returns true if a 'hIST' chunk will be output. |
boolean |
isPhysicalDimensionSet()
Returns true if a 'pHYS' chunk will be output. |
boolean |
isSignificantBitsSet()
Returns true if an 'sBIT' chunk will be output. |
boolean |
isSRGBIntentSet()
Returns true if an 'sRGB' chunk will be output. |
boolean |
isSuggestedPaletteSet()
Returns true if a 'sPLT' chunk will be output. |
boolean |
isTextSet()
Returns true if a 'tEXt' chunk will be output. |
boolean |
isTransparencySet()
Returns true if a 'tRNS' chunk will be output. |
static int |
paethPredictor(int a,
int b,
int c)
The Paeth predictor routine used in PNG encoding. |
void |
removeAllPrivateChunks()
Remove all private chunks associated with this parameter instance. |
void |
removeUnsafeToCopyPrivateChunks()
Remove all private chunks associated with this parameter instance whose 'safe-to-copy' bit is not set. |
abstract void |
setBitDepth(int bitDepth)
Sets the desired bit depth of an image. |
void |
setChromaticity(float[] chromaticity)
Sets the white point and primary chromaticities in CIE (x, y) space. |
void |
setChromaticity(float whitePointX,
float whitePointY,
float redX,
float redY,
float greenX,
float greenY,
float blueX,
float blueY)
A convenience method that calls the array version. |
void |
setCompressedText(String[] text)
Sets the text strings to be stored in compressed form with this image. |
void |
setGamma(float gamma)
Sets the file gamma value for the image. |
void |
setICCProfileData(byte[] ICCProfileData)
Sets the ICC profile data to be stored with this image. |
void |
setInterlacing(boolean useInterlacing)
Turns Adam7 interlacing on or off. |
void |
setModificationTime(Date modificationTime)
Sets the modification time, as a Date , to be
stored with this image. |
void |
setPaletteHistogram(int[] paletteHistogram)
Sets the palette histogram to be stored with this image. |
void |
setPhysicalDimension(int[] physicalDimension)
Sets the physical dimension information to be stored with this image. |
void |
setPhysicalDimension(int xPixelsPerUnit,
int yPixelsPerUnit,
int unitSpecifier)
A convenience method that calls the array version. |
void |
setSignificantBits(int[] significantBits)
Sets the number of significant bits for each band of the image. |
void |
setSRGBIntent(int SRGBIntent)
Sets the sRGB rendering intent to be stored with this image. |
void |
setSuggestedPalette(mxPngSuggestedPaletteEntry[] palette)
Sets the suggested palette information to be stored with this image. |
void |
setText(String[] text)
Sets the textual data to be stored in uncompressed form with this image. |
void |
unsetBackground()
Suppresses the 'bKGD' chunk from being output. |
void |
unsetBitDepth()
Suppresses the setting of the bit depth of a grayscale image. |
void |
unsetChromaticity()
Suppresses the 'cHRM' chunk from being output. |
void |
unsetCompressedText()
Suppresses the 'zTXt' chunk from being output. |
void |
unsetGamma()
Suppresses the 'gAMA' chunk from being output. |
void |
unsetICCProfileData()
Suppresses the 'iCCP' chunk from being output. |
void |
unsetModificationTime()
Suppresses the 'tIME' chunk from being output. |
void |
unsetPaletteHistogram()
Suppresses the 'hIST' chunk from being output. |
void |
unsetPhysicalDimension()
Suppresses the 'pHYS' chunk from being output. |
void |
unsetSignificantBits()
Suppresses the 'sBIT' chunk from being output. |
void |
unsetSRGBIntent()
Suppresses the 'sRGB' chunk from being output. |
void |
unsetSuggestedPalette()
Suppresses the 'sPLT' chunk from being output. |
void |
unsetText()
Suppresses the 'tEXt' chunk from being output. |
void |
unsetTransparency()
Suppresses the 'tRNS' chunk from being output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INTENT_PERCEPTUAL
public static final int INTENT_RELATIVE
public static final int INTENT_SATURATION
public static final int INTENT_ABSOLUTE
public static final int PNG_FILTER_NONE
public static final int PNG_FILTER_SUB
public static final int PNG_FILTER_UP
public static final int PNG_FILTER_AVERAGE
public static final int PNG_FILTER_PAETH
protected int bitDepth
protected boolean bitDepthSet
Constructor Detail |
---|
public mxPngEncodeParam()
Method Detail |
---|
public static mxPngEncodeParam getDefaultEncodeParam(RenderedImage im)
PNGEncodeParam.Palette
,
PNGEncodeParam.Gray
, or
PNGEncodeParam.RGB
appropriate for encoding
the given image.
If the image has an IndexColorModel
, an
instance of PNGEncodeParam.Palette
is returned.
Otherwise, if the image has 1 or 2 bands an instance of
PNGEncodeParam.Gray
is returned. In all other
cases an instance of PNGEncodeParam.RGB
is
returned.
Note that this method does not provide any guarantee that the given image will be successfully encoded by the PNG encoder, as it only performs a very superficial analysis of the image structure.
public abstract void setBitDepth(int bitDepth)
public int getBitDepth()
If the bit depth has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the bit depth is not set.public void unsetBitDepth()
public void setInterlacing(boolean useInterlacing)
public boolean getInterlacing()
true
if Adam7 interlacing will be used.
public void unsetBackground()
RuntimeException
;
accordingly, subclasses must provide their own implementations.
public boolean isBackgroundSet()
RuntimeException
;
accordingly, subclasses must provide their own implementations.
public void setChromaticity(float[] chromaticity)
The chromaticity
parameter should be a
float
array of length 8 containing the white point
X and Y, red X and Y, green X and Y, and blue X and Y values in
order.
The 'cHRM' chunk will encode this information.
public void setChromaticity(float whitePointX, float whitePointY, float redX, float redY, float greenX, float greenY, float blueX, float blueY)
public float[] getChromaticity()
See the documentation for the setChromaticity
method for the format of the returned data.
If the chromaticity has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the chromaticity is not set.public void unsetChromaticity()
public boolean isChromaticitySet()
public void setGamma(float gamma)
The 'gAMA' chunk will encode this information.
public float getGamma()
If the file gamma has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the gamma is not set.public void unsetGamma()
public boolean isGammaSet()
public void setPaletteHistogram(int[] paletteHistogram)
The 'hIST' chunk will encode this information.
public int[] getPaletteHistogram()
If the histogram has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the histogram is not set.public void unsetPaletteHistogram()
public boolean isPaletteHistogramSet()
public void setICCProfileData(byte[] ICCProfileData)
The 'iCCP' chunk will encode this information.
public byte[] getICCProfileData()
If the ICC profile has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the ICC profile is not set.public void unsetICCProfileData()
public boolean isICCProfileDataSet()
public void setPhysicalDimension(int[] physicalDimension)
The 'pHYS' chunk will encode this information.
public void setPhysicalDimension(int xPixelsPerUnit, int yPixelsPerUnit, int unitSpecifier)
public int[] getPhysicalDimension()
If the physical dimension information has not previously
been set, or has been unset, an
IllegalStateException
will be thrown.
IllegalStateException
- if the physical dimension information
is not set.public void unsetPhysicalDimension()
public boolean isPhysicalDimensionSet()
public void setSuggestedPalette(mxPngSuggestedPaletteEntry[] palette)
PNGSuggestedPaletteEntry
objects.
The 'sPLT' chunk will encode this information.
public void unsetSuggestedPalette()
public boolean isSuggestedPaletteSet()
public void setSignificantBits(int[] significantBits)
The number of entries in the significantBits
array must be equal to the number of output bands in the image:
1 for a gray image, 2 for gray+alpha, 3 for index or truecolor,
and 4 for truecolor+alpha.
The 'sBIT' chunk will encode this information.
public int[] getSignificantBits()
If the significant bits values have not previously been
set, or have been unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the significant bits values are
not set.public void unsetSignificantBits()
public boolean isSignificantBitsSet()
public void setSRGBIntent(int SRGBIntent)
The 'sRGB' chunk will encode this information.
public int getSRGBIntent()
If the sRGB intent has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the sRGB intent is not set.public void unsetSRGBIntent()
public boolean isSRGBIntentSet()
public void setText(String[] text)
String
s.
The 'tEXt' chunk will encode this information.
public String[] getText()
String
s.
If the text strings have not previously been set, or have been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the text strings are not set.public void unsetText()
public boolean isTextSet()
public void setModificationTime(Date modificationTime)
Date
, to be
stored with this image. The internal storage format will use
UTC regardless of how the modificationTime
parameter was created.
The 'tIME' chunk will encode this information.
public Date getModificationTime()
If the bit depth has not previously been set, or has been
unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the bit depth is not set.public void unsetModificationTime()
public boolean isModificationTimeSet()
public void unsetTransparency()
public boolean isTransparencySet()
public void setCompressedText(String[] text)
String
s.
The 'zTXt' chunk will encode this information.
public String[] getCompressedText()
String
s.
If the compressed text strings have not previously been
set, or have been unset, an IllegalStateException
will be thrown.
IllegalStateException
- if the compressed text strings are
not set.public void unsetCompressedText()
public boolean isCompressedTextSet()
public void addPrivateChunk(String type, byte[] data)
type
- a 4-character String giving the chunk type name.data
- an array of byte
s containing the
chunk data.public int getNumPrivateChunks()
public String getPrivateChunkType(int index)
String
. The index must be smaller
than the return value of getNumPrivateChunks
.
public byte[] getPrivateChunkData(int index)
byte
s. The index must be
smaller than the return value of
getNumPrivateChunks
.
public void removeUnsafeToCopyPrivateChunks()
public void removeAllPrivateChunks()
public static final int paethPredictor(int a, int b, int c)
filterRow
method.
public int filterRow(byte[] currRow, byte[] prevRow, byte[][] scratchRows, int bytesPerRow, int bytesPerPixel)
The method is supplied with the current and previous rows of the image. For the first row of the image, or of an interlacing pass, the previous row array will be filled with zeros as required by the PNG specification.
The method is also supplied with five scratch arrays. These arrays may be used within the method for any purpose. At method exit, the array at the index given by the return value of the method should contain the filtered data. The return value will also be used as the filter type.
The default implementation of the method performs a trial encoding with each of the filter types, and computes the sum of absolute values of the differences between the raw bytes of the current row and the predicted values. The index of the filter producing the smallest result is returned.
As an example, to perform only 'sub' filtering, this method could be implemented (non-optimally) as follows:
for (int i = bytesPerPixel; i < bytesPerRow + bytesPerPixel; i++) { int curr = currRow[i] & 0xff; int left = currRow[i - bytesPerPixel] & 0xff; scratchRow[PNG_FILTER_SUB][i] = (byte)(curr - left); } return PNG_FILTER_SUB;
currRow
- The current row as an array of byte
s
of length at least bytesPerRow + bytesPerPixel
.
The pixel data starts at index bytesPerPixel
;
the initial bytesPerPixel
bytes are zero.prevRow
- The current row as an array of byte
s
The pixel data starts at index bytesPerPixel
;
the initial bytesPerPixel
bytes are zero.scratchRows
- An array of 5 byte
arrays of
length at least bytesPerRow +
bytesPerPixel
, useable to hold temporary results.
The filtered row will be returned as one of the entries
of this array. The returned filtered data should start
at index bytesPerPixel
; The initial
bytesPerPixel
bytes are not used.bytesPerRow
- The number of bytes in the image row.
This value will always be greater than 0.bytesPerPixel
- The number of bytes representing a single
pixel, rounded up to an integer. This is the 'bpp' parameter
described in the PNG specification.
scratchRows[]
at this index holds the
filtered data.
|
mxGraph 1.10.0.5 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |