Class BMPImageWriteParam
ImageWriteParam
for encoding images in
the BMP format.
This class allows for the specification of various parameters while writing a BMP format image file. By default, the data layout is bottom-up, such that the pixels are stored in bottom-up order, the first scanline being stored last.
The particular compression scheme to be used can be specified by using
the setCompressionType()
method with the appropriate type
string. The compression scheme specified will be honored if and only if it
is compatible with the type of image being written. If the specified
compression scheme is not compatible with the type of image being written
then the IOException
will be thrown by the BMP image writer.
If the compression type is not set explicitly then getCompressionType()
will return null
. In this case the BMP image writer will select
a compression type that supports encoding of the given image without loss
of the color resolution.
The compression type strings and the image type(s) each supports are listed in the following table:
Type String | Description | Image Types |
---|---|---|
BI_RGB | Uncompressed RLE | <= 8-bits/sample |
BI_RLE8 | 8-bit Run Length Encoding | <= 8-bits/sample |
BI_RLE4 | 4-bit Run Length Encoding | <= 4-bits/sample |
BI_BITFIELDS | Packed data | 16 or 32 bits/sample |
-
Field Summary
Fields declared in class ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, compressionMode, compressionQuality, compressionType, compressionTypes, locale, MODE_COPY_FROM_METADATA, MODE_DEFAULT, MODE_DISABLED, MODE_EXPLICIT, preferredTileSizes, progressiveMode, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, tilingMode, tilingSet
Modifier and TypeFieldDescriptionprotected boolean
Aboolean
that istrue
if thisImageWriteParam
allows tiling grid offset parameters to be set.protected boolean
Aboolean
that istrue
if this writer can write images using compression.protected boolean
Aboolean
that istrue
if thisImageWriteParam
allows images to be written as a progressive sequence of increasing quality passes.protected boolean
Aboolean
that istrue
if thisImageWriteParam
allows tile width and tile height parameters to be set.protected int
The mode controlling compression settings, which must be set to one of the fourMODE_*
values.protected float
Afloat
containing the current compression quality setting.protected String
AString
containing the name of the current compression type, ornull
if none is set.protected String[]
An array ofString
s containing the names of the available compression types.protected Locale
ALocale
to be used to localize compression type names and quality descriptions, ornull
to use a defaultLocale
.static final int
A constant value that may be passed into methods such assetTilingMode
,setProgressiveMode
, orsetCompressionMode
to enable that feature for future writes.static final int
A constant value that may be passed into methods such assetTilingMode
,setProgressiveMode
, andsetCompressionMode
to enable that feature for future writes.static final int
A constant value that may be passed into methods such assetTilingMode
,setProgressiveMode
, andsetCompressionMode
to disable a feature for future writes.static final int
A constant value that may be passed into methods such assetTilingMode
orsetCompressionMode
to enable a feature for future writes.protected Dimension[]
An array of preferred tile size range pairs.protected int
The mode controlling progressive encoding, which must be set to one of the fourMODE_*
values, exceptMODE_EXPLICIT
.protected int
The amount by which the tile grid origin should be offset horizontally from the image origin if tiling has been set, or 0 otherwise.protected int
The amount by which the tile grid origin should be offset vertically from the image origin if tiling has been set, or 0 otherwise.protected int
The height of each tile if tiling has been set, or 0 otherwise.protected int
The width of each tile if tiling has been set, or 0 otherwise.protected int
The mode controlling tiling settings, which Must be set to one of the fourMODE_*
values.protected boolean
Aboolean
that istrue
if tiling parameters have been specified.Fields declared in class IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
Modifier and TypeFieldDescriptionprotected IIOParamController
TheIIOParamController
that will be used to provide settings for thisIIOParam
object when theactivateController
method is called.protected IIOParamController
The defaultIIOParamController
that will be used to provide settings for thisIIOParam
object when theactivateController
method is called.protected Point
The offset in the destination where the upper-left decoded pixel should be placed.protected ImageTypeSpecifier
AnImageTypeSpecifier
to be used to generate a destination image when reading, or to set the output color type when writing.protected int[]
An array ofint
s indicating which source bands will be used, ornull
.protected Rectangle
The source region, onnull
if none is set.protected int
The decimation subsampling to be applied in the horizontal direction.protected int
The decimation subsampling to be applied in the vertical direction.protected int
A horizontal offset to be applied to the subsampling grid before subsampling.protected int
A vertical offset to be applied to the subsampling grid before subsampling. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs anBMPImageWriteParam
object with default values for all parameters and anull Locale
.BMPImageWriteParam
(Locale locale) Constructs aBMPImageWriteParam
set to use a givenLocale
and with default values for all parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the value of thetopDown
parameter.void
setTopDown
(boolean topDown) If set, the data will be written out in a top-down manner, the first scanline being written first.Methods declared in class ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, getBitRate, getCompressionMode, getCompressionQuality, getCompressionQualityDescriptions, getCompressionQualityValues, getCompressionType, getCompressionTypes, getLocale, getLocalizedCompressionTypeName, getPreferredTileSizes, getProgressiveMode, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTilingMode, isCompressionLossless, setCompressionMode, setCompressionQuality, setCompressionType, setProgressiveMode, setTiling, setTilingMode, unsetCompression, unsetTiling
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the writer can perform tiling with non-zero grid offsets while writing.boolean
Returnstrue
if this writer supports compression.boolean
Returnstrue
if the writer can write out images as a series of passes of progressively increasing quality.boolean
Returnstrue
if the writer can perform tiling while writing.float
getBitRate
(float quality) Returns afloat
indicating an estimate of the number of bits of output data for each bit of input image data at the given quality level.int
Returns the current compression mode, if compression is supported.float
Returns the current compression quality setting.String[]
Returns an array ofString
s that may be used along withgetCompressionQualityValues
as part of a user interface for setting or displaying the compression quality level.float[]
Returns an array offloat
s that may be used along withgetCompressionQualityDescriptions
as part of a user interface for setting or displaying the compression quality level.Returns the currently set compression type, ornull
if none has been set.String[]
Returns a list of available compression types, as an array orString
s, ornull
if a compression type may not be chosen using these interfaces.Returns the currently setLocale
, ornull
if only a defaultLocale
is supported.Returns a localized version of the name of the current compression type, using theLocale
returned bygetLocale
.Returns an array ofDimension
s indicating the legal size ranges for tiles as they will be encoded in the output file or stream.int
Returns the current mode for writing the stream in a progressive manner.int
Returns the horizontal tile grid offset of an image as it will be written to the output stream.int
Returns the vertical tile grid offset of an image as it will be written to the output stream.int
Returns the height of each tile in an image as it will be written to the output stream.int
Returns the width of each tile in an image as it will be written to the output stream.int
Returns the current tiling mode, if tiling is supported.boolean
Returnstrue
if the current compression type provides lossless compression.void
setCompressionMode
(int mode) Specifies whether compression is to be performed, and if so how compression parameters are to be determined.void
setCompressionQuality
(float quality) Sets the compression quality to a value between0
and1
.void
setCompressionType
(String compressionType) Sets the compression type to one of the values indicated bygetCompressionTypes
.void
setProgressiveMode
(int mode) Specifies that the writer is to write the image out in a progressive mode such that the stream will contain a series of scans of increasing quality.void
setTiling
(int tileWidth, int tileHeight, int tileGridXOffset, int tileGridYOffset) Specifies that the image should be tiled in the output stream.void
setTilingMode
(int mode) Determines whether the image will be tiled in the output stream and, if it will, how the tiling parameters will be determined.void
Removes any previous compression type and quality settings.void
Removes any previous tile grid parameters specified by calls tosetTiling
.Methods declared in class IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceBands, setSourceRegion, setSourceSubsampling
Modifier and TypeMethodDescriptionboolean
Activates the installedIIOParamController
for thisIIOParam
object and returns the resulting value.Returns whateverIIOParamController
is currently installed.Returns the defaultIIOParamController
, if there is one, regardless of the currently installed controller.Returns the offset in the destination image at which pixels are to be placed.Returns the type of image to be returned by the read, if one was set by a call tosetDestination(ImageTypeSpecifier)
, as anImageTypeSpecifier
.int[]
Returns the set of source bands to be used.Returns the source region to be used.int
Returns the number of source columns to advance for each pixel.int
Returns the number of rows to advance for each pixel.int
Returns the horizontal offset of the subsampling grid.int
Returns the vertical offset of the subsampling grid.boolean
Returnstrue
if there is a controller installed for thisIIOParam
object.void
setController
(IIOParamController controller) Sets theIIOParamController
to be used to provide settings for thisIIOParam
object when theactivateController
method is called, overriding any default controller.void
setDestinationOffset
(Point destinationOffset) Specifies the offset in the destination image at which future decoded pixels are to be placed, when reading, or where a region will be written, when writing.void
setDestinationType
(ImageTypeSpecifier destinationType) Sets the desired image type for the destination image, using anImageTypeSpecifier
.void
setSourceBands
(int[] sourceBands) Sets the indices of the source bands to be used.void
setSourceRegion
(Rectangle sourceRegion) Sets the source region of interest.void
setSourceSubsampling
(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset) Specifies a decimation subsampling to apply on I/O.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
BMPImageWriteParam
Constructs aBMPImageWriteParam
set to use a givenLocale
and with default values for all parameters.- Parameters:
locale
- aLocale
to be used to localize compression type names and quality descriptions, ornull
.
-
BMPImageWriteParam
public BMPImageWriteParam()Constructs anBMPImageWriteParam
object with default values for all parameters and anull Locale
.
-
-
Method Details
-
setTopDown
public void setTopDown(boolean topDown) If set, the data will be written out in a top-down manner, the first scanline being written first.- Parameters:
topDown
- whether the data are written in top-down order.
-
isTopDown
public boolean isTopDown()Returns the value of thetopDown
parameter. The default isfalse
.- Returns:
- whether the data are written in top-down order.
-