Fields Summary |
---|
public static final int | MODE_DISABLEDThe Constant MODE_DISABLED indicates that stream is not tiled,
progressive, or compressed. |
public static final int | MODE_DEFAULTThe Constant MODE_DEFAULT indicates that the stream will be tiled,
progressive, or compressed according to the plug-in's default. |
public static final int | MODE_EXPLICITThe Constant MODE_EXPLICIT indicates that the stream will be tiled,
progressive, or compressed according to current settings which are
defined by set methods. |
public static final int | MODE_COPY_FROM_METADATAThe Constant MODE_COPY_FROM_METADATA indicates that the stream will be
tiled, progressive, or compressed according to stream or image metadata. |
protected boolean | canWriteTilesWhether the ImageWriter can write tiles. |
protected int | tilingModeThe tiling mode. |
protected Dimension[] | preferredTileSizesThe preferred tile sizes. |
protected boolean | tilingSetThe tiling set. |
protected int | tileWidthThe tile width. |
protected int | tileHeightThe tile height. |
protected boolean | canOffsetTilesWhether the ImageWriter can offset tiles. |
protected int | tileGridXOffsetThe tile grid x offset. |
protected int | tileGridYOffsetThe tile grid y offset. |
protected boolean | canWriteProgressiveWhether the ImageWriter can write in progressive mode. |
protected int | progressiveModeThe progressive mode. |
protected boolean | canWriteCompressedWhether the ImageWriter can write in compressed mode. |
protected int | compressionModeThe compression mode. |
protected String[] | compressionTypesThe compression types. |
protected String | compressionTypeThe compression type. |
protected float | compressionQualityThe compression quality. |
protected Locale | localeThe locale. |
Methods Summary |
---|
public boolean | canOffsetTiles()Returns true if the writer can use tiles with non zero grid offsets while
writing.
return canOffsetTiles;
|
public boolean | canWriteCompressed()Returns true if this writer can write images with compression.
return canWriteCompressed;
|
public boolean | canWriteProgressive()Returns true if images can be written using increasing quality passes by
progressive.
return canWriteProgressive;
|
public boolean | canWriteTiles()Returns true if the writer can write tiles.
return canWriteTiles;
|
private final void | checkCompressionMode()Check compression mode.
if (getCompressionMode() != MODE_EXPLICIT) {
throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
}
|
private final void | checkCompressionType()Check compression type.
if (getCompressionTypes() != null && getCompressionType() == null) {
throw new IllegalStateException("No compression type set!");
}
|
private final void | checkTiling()Check tiling.
if (!canWriteTiles()) {
throw new UnsupportedOperationException("Tiling not supported!");
}
|
private final void | checkTilingMode()Check tiling mode.
if (getTilingMode() != MODE_EXPLICIT) {
throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
}
|
private final void | checkTilingParams()Check tiling params.
if (!tilingSet) {
throw new IllegalStateException("Tiling parameters not set!");
}
|
private final void | checkWriteCompressed()Check write compressed.
if (!canWriteCompressed()) {
throw new UnsupportedOperationException("Compression not supported.");
}
|
public float | getBitRate(float quality)Gets a bit rate which represents an estimate of the number of bits of
output data for each bit of input image data with the specified quality.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
if (quality < 0 || quality > 1) {
throw new IllegalArgumentException("Quality out-of-bounds!");
}
return -1.0f;
|
public int | getCompressionMode()Gets the compression mode.
checkWriteCompressed();
return compressionMode;
|
public float | getCompressionQuality()Gets the compression quality.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
return compressionQuality;
|
public java.lang.String[] | getCompressionQualityDescriptions()Gets the array of compression quality descriptions.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
return null;
|
public float[] | getCompressionQualityValues()Gets an array of floats which describes compression quality levels.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
return null;
|
public java.lang.String | getCompressionType()Gets the current compression type, or returns null.
checkWriteCompressed();
checkCompressionMode();
return compressionType;
|
public java.lang.String[] | getCompressionTypes()Gets the an array of supported compression types.
checkWriteCompressed();
if (compressionTypes != null) {
return compressionTypes.clone();
}
return null;
|
public java.util.Locale | getLocale()Gets the locale of this ImageWriteParam.
return locale;
|
public java.lang.String | getLocalizedCompressionTypeName()Gets the current compression type using the current Locale.
checkWriteCompressed();
checkCompressionMode();
String compressionType = getCompressionType();
if (compressionType == null) {
throw new IllegalStateException("No compression type set!");
}
return compressionType;
|
public java.awt.Dimension[] | getPreferredTileSizes()Gets an array of Dimensions giving the sizes of the tiles as they are
encoded in the output file or stream.
checkTiling();
if (preferredTileSizes == null) {
return null;
}
Dimension[] retval = new Dimension[preferredTileSizes.length];
for (int i = 0; i < preferredTileSizes.length; i++) {
retval[i] = new Dimension(retval[i]);
}
return retval;
|
public int | getProgressiveMode()Gets the mode for writing the stream in a progressive sequence.
if (canWriteProgressive()) {
return progressiveMode;
}
throw new UnsupportedOperationException("progressive mode is not supported");
|
public int | getTileGridXOffset()Gets the tile grid X offset for encoding.
checkTiling();
checkTilingMode();
checkTilingParams();
return tileGridXOffset;
|
public int | getTileGridYOffset()Gets the tile grid Y offset for encoding.
checkTiling();
checkTilingMode();
checkTilingParams();
return tileGridYOffset;
|
public int | getTileHeight()Gets the tile height in an image as it is written to the output stream.
checkTiling();
checkTilingMode();
checkTilingParams();
return tileHeight;
|
public int | getTileWidth()Gets the tile width in an image as it is written to the output stream.
checkTiling();
checkTilingMode();
checkTilingParams();
return tileWidth;
|
public int | getTilingMode()Gets the tiling mode if tiling is supported.
checkTiling();
return tilingMode;
|
public boolean | isCompressionLossless()Checks if the current compression type has lossless compression or not.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
return true;
|
public void | setCompressionMode(int mode)Sets the compression mode to the specified value. The specified mode can
be one of the predefined constants: MODE_DEFAULT, MODE_DISABLED,
MODE_EXPLICIT, or MODE_COPY_FROM_METADATA.
checkWriteCompressed();
switch (mode) {
case MODE_EXPLICIT: {
compressionMode = mode;
unsetCompression();
break;
}
case MODE_COPY_FROM_METADATA:
case MODE_DISABLED:
case MODE_DEFAULT: {
compressionMode = mode;
break;
}
default: {
throw new IllegalArgumentException("Illegal value for mode!");
}
}
|
public void | setCompressionQuality(float quality)Sets the compression quality. The value should be between 0 and 1.
checkWriteCompressed();
checkCompressionMode();
checkCompressionType();
if (quality < 0 || quality > 1) {
throw new IllegalArgumentException("Quality out-of-bounds!");
}
compressionQuality = quality;
|
public void | setCompressionType(java.lang.String compressionType)Sets the compression type. The specified string should be one of the
values returned by getCompressionTypes method.
checkWriteCompressed();
checkCompressionMode();
if (compressionType == null) { // Don't check anything
this.compressionType = null;
} else {
String[] compressionTypes = getCompressionTypes();
if (compressionTypes == null) {
throw new UnsupportedOperationException("No settable compression types");
}
for (int i = 0; i < compressionTypes.length; i++) {
if (compressionTypes[i].equals(compressionType)) {
this.compressionType = compressionType;
return;
}
}
// Compression type is not in the list.
throw new IllegalArgumentException("Unknown compression type!");
}
|
public void | setProgressiveMode(int mode)Sets the progressive mode which defines whether the stream contains a
progressive sequence of increasing quality during writing. The
progressive mode should be one of the following values: MODE_DISABLED,
MODE_DEFAULT, or MODE_COPY_FROM_METADATA.
if (canWriteProgressive()) {
if (mode < MODE_DISABLED || mode > MODE_COPY_FROM_METADATA || mode == MODE_EXPLICIT) {
throw new IllegalArgumentException("mode is not supported");
}
this.progressiveMode = mode;
}
throw new UnsupportedOperationException("progressive mode is not supported");
|
public void | setTiling(int tileWidth, int tileHeight, int tileGridXOffset, int tileGridYOffset)Sets the instruction that tiling should be performed for the image in the
output stream with the specified parameters.
checkTiling();
checkTilingMode();
if (!canOffsetTiles() && (tileGridXOffset != 0 || tileGridYOffset != 0)) {
throw new UnsupportedOperationException("Can't offset tiles!");
}
if (tileWidth <= 0 || tileHeight <= 0) {
throw new IllegalArgumentException("tile dimensions are non-positive!");
}
Dimension preferredTileSizes[] = getPreferredTileSizes();
if (preferredTileSizes != null) {
for (int i = 0; i < preferredTileSizes.length; i += 2) {
Dimension minSize = preferredTileSizes[i];
Dimension maxSize = preferredTileSizes[i + 1];
if (tileWidth < minSize.width || tileWidth > maxSize.width
|| tileHeight < minSize.height || tileHeight > maxSize.height) {
throw new IllegalArgumentException("Illegal tile size!");
}
}
}
tilingSet = true;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.tileGridXOffset = tileGridXOffset;
this.tileGridYOffset = tileGridYOffset;
|
public void | setTilingMode(int mode)Sets the tiling mode. The specified mode should be one of the following
values: MODE_DISABLED, MODE_DEFAULT, MODE_EXPLICIT, or
MODE_COPY_FROM_METADATA.
checkTiling();
switch (mode) {
case MODE_EXPLICIT: {
tilingMode = mode;
unsetTiling();
break;
}
case MODE_COPY_FROM_METADATA:
case MODE_DISABLED:
case MODE_DEFAULT: {
tilingMode = mode;
break;
}
default: {
throw new IllegalArgumentException("Illegal value for mode!");
}
}
|
public void | unsetCompression()Removes current compression type.
checkWriteCompressed();
checkCompressionMode();
compressionType = null;
compressionQuality = 1;
|
public void | unsetTiling()Clears all tiling settings.
checkTiling();
checkTilingMode();
tilingSet = false;
tileWidth = 0;
tileHeight = 0;
tileGridXOffset = 0;
tileGridYOffset = 0;
|