public class ImageUtil
extends java.lang.Object
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
canEncodeImage(javax.imageio.ImageWriter writer,
java.awt.image.ColorModel colorModel,
java.awt.image.SampleModel sampleModel)
Checks that the provided
ImageWriter can encode
the provided ColorModel and SampleModel . |
static void |
canEncodeImage(javax.imageio.ImageWriter writer,
javax.imageio.ImageTypeSpecifier type)
Checks that the provided
ImageWriter can encode
the provided ImageTypeSpecifier or not. |
static java.lang.String |
convertObjectToString(java.lang.Object obj)
Converts the provided object to
String |
static java.awt.image.ColorModel |
createColorModel(java.awt.color.ColorSpace colorSpace,
java.awt.image.SampleModel sampleModel) |
static java.awt.image.ColorModel |
createColorModel(java.awt.image.SampleModel sampleModel)
Creates a
ColorModel that may be used with the
specified SampleModel . |
static long |
getBandSize(java.awt.image.SampleModel sm) |
static javax.imageio.ImageTypeSpecifier |
getDestinationType(javax.imageio.ImageReadParam param,
java.util.Iterator imageTypes)
Gets the destination image type.
|
static int |
getElementSize(java.awt.image.SampleModel sm) |
static java.util.List |
getJDKImageReaderWriterSPI(javax.imageio.spi.ServiceRegistry registry,
java.lang.String formatName,
boolean isReader) |
static byte[] |
getPackedBinaryData(java.awt.image.Raster raster,
java.awt.Rectangle rect)
For the case of binary data (
isBinary() returns
true ), return the binary data as a packed byte array. |
static long |
getTileSize(java.awt.image.SampleModel sm) |
static byte[] |
getUnpackedBinaryData(java.awt.image.Raster raster,
java.awt.Rectangle rect)
Returns the binary data unpacked into an array of bytes.
|
static boolean |
imageIsContiguous(java.awt.image.RenderedImage image)
Returns whether the image has contiguous data across rows.
|
static boolean |
isBinary(java.awt.image.SampleModel sm) |
static boolean |
isGrayscaleMapping(java.awt.image.IndexColorModel icm)
Tests whether the color indices represent a gray-scale image with
the indicated number of bits over the color component range [0,255].
|
static boolean |
isIndicesForGrayscale(byte[] r,
byte[] g,
byte[] b)
Tests whether the color indices represent a gray-scale image.
|
static boolean |
isNonStandardICCColorSpace(java.awt.color.ColorSpace cs)
Returns
true if the given ColorSpace object
is an instance of ICC_ColorSpace but is not one of the
standard ColorSpace s returned by
ColorSpace.getInstance() . |
static void |
processOnRegistration(javax.imageio.spi.ServiceRegistry registry,
java.lang.Class category,
java.lang.String formatName,
javax.imageio.spi.ImageReaderWriterSpi spi,
int deregisterJvmVersion,
int priorityJvmVersion) |
static int |
readMultiByteInteger(javax.imageio.stream.ImageInputStream iis) |
static void |
setPackedBinaryData(byte[] binaryDataArray,
java.awt.image.WritableRaster raster,
java.awt.Rectangle rect)
Sets the supplied
Raster 's data from an array
of packed binary data of the form returned by
getPackedBinaryData() . |
static void |
setUnpackedBinaryData(byte[] bdata,
java.awt.image.WritableRaster raster,
java.awt.Rectangle rect)
Copies data into the packed array of the
Raster
from an array of unpacked data of the form returned by
getUnpackedBinaryData() . |
public static final java.awt.image.ColorModel createColorModel(java.awt.image.SampleModel sampleModel)
ColorModel
that may be used with the
specified SampleModel
. If a suitable
ColorModel
cannot be found, this method returns
null
.
Suitable ColorModel
s are guaranteed to exist
for all instances of ComponentSampleModel
.
For 1- and 3- banded SampleModel
s, the returned
ColorModel
will be opaque. For 2- and 4-banded
SampleModel
s, the output will use alpha transparency
which is not premultiplied. 1- and 2-banded data will use a
grayscale ColorSpace
, and 3- and 4-banded data a sRGB
ColorSpace
. Data with 5 or more bands will have a
BogusColorSpace
.
An instance of DirectColorModel
will be created for
instances of SinglePixelPackedSampleModel
with no more
than 4 bands.
An instance of IndexColorModel
will be created for
instances of MultiPixelPackedSampleModel
. The colormap
will be a grayscale ramp with 1 << numberOfBits
entries ranging from zero to at most 255.
ColorModel
that is suitable for
the supplied SampleModel
, or null
.java.lang.IllegalArgumentException
- If sampleModel
is
null
.public static byte[] getPackedBinaryData(java.awt.image.Raster raster, java.awt.Rectangle rect)
isBinary()
returns
true
), return the binary data as a packed byte array.
The data will be packed as eight bits per byte with no bit offset,
i.e., the first bit in each image line will be the left-most of the
first byte of the line. The line stride in bytes will be
(int)((getWidth()+7)/8)
. The length of the returned
array will be the line stride multiplied by getHeight()
null
if the data are not binary.java.lang.IllegalArgumentException
- if isBinary()
returns
false
with the SampleModel
of the
supplied Raster
as argument.public static byte[] getUnpackedBinaryData(java.awt.image.Raster raster, java.awt.Rectangle rect)
Raster
.java.lang.IllegalArgumentException
- if isBinary()
returns
false
with the SampleModel
of the
supplied Raster
as argument.public static void setPackedBinaryData(byte[] binaryDataArray, java.awt.image.WritableRaster raster, java.awt.Rectangle rect)
Raster
's data from an array
of packed binary data of the form returned by
getPackedBinaryData()
.java.lang.IllegalArgumentException
- if isBinary()
returns
false
with the SampleModel
of the
supplied Raster
as argument.public static void setUnpackedBinaryData(byte[] bdata, java.awt.image.WritableRaster raster, java.awt.Rectangle rect)
Raster
from an array of unpacked data of the form returned by
getUnpackedBinaryData()
.
If the data are binary, then the target bit will be set if and only if the corresponding byte is non-zero.
java.lang.IllegalArgumentException
- if isBinary()
returns
false
with the SampleModel
of the
supplied Raster
as argument.public static boolean isBinary(java.awt.image.SampleModel sm)
public static java.awt.image.ColorModel createColorModel(java.awt.color.ColorSpace colorSpace, java.awt.image.SampleModel sampleModel)
public static int getElementSize(java.awt.image.SampleModel sm)
public static long getTileSize(java.awt.image.SampleModel sm)
public static long getBandSize(java.awt.image.SampleModel sm)
public static boolean isGrayscaleMapping(java.awt.image.IndexColorModel icm)
icm
- The gray-to-color mapping.IndexColorModel
maps index
i
to ((255*i)/icm.getMapSize()-1)
.java.lang.IllegalArgumentException
- if icm
is
null
.public static boolean isIndicesForGrayscale(byte[] r, byte[] g, byte[] b)
r
- The red channel color indices.g
- The green channel color indices.b
- The blue channel color indices.true
; otherwise, return false
.public static java.lang.String convertObjectToString(java.lang.Object obj)
String
public static final void canEncodeImage(javax.imageio.ImageWriter writer, javax.imageio.ImageTypeSpecifier type) throws javax.imageio.IIOException
ImageWriter
can encode
the provided ImageTypeSpecifier
or not. If not, an
IIOException
will be thrown.writer
- The provided ImageWriter
.type
- The image to be tested.javax.imageio.IIOException
- If the writer cannot encoded the provided image.public static final void canEncodeImage(javax.imageio.ImageWriter writer, java.awt.image.ColorModel colorModel, java.awt.image.SampleModel sampleModel) throws javax.imageio.IIOException
ImageWriter
can encode
the provided ColorModel
and SampleModel
.
If not, an IIOException
will be thrown.writer
- The provided ImageWriter
.colorModel
- The provided ColorModel
.sampleModel
- The provided SampleModel
.javax.imageio.IIOException
- If the writer cannot encoded the provided image.public static final boolean imageIsContiguous(java.awt.image.RenderedImage image)
public static final javax.imageio.ImageTypeSpecifier getDestinationType(javax.imageio.ImageReadParam param, java.util.Iterator imageTypes) throws javax.imageio.IIOException
javax.imageio.IIOException
public static boolean isNonStandardICCColorSpace(java.awt.color.ColorSpace cs)
true
if the given ColorSpace
object
is an instance of ICC_ColorSpace
but is not one of the
standard ColorSpace
s returned by
ColorSpace.getInstance()
.cs
- The ColorSpace
to test.public static java.util.List getJDKImageReaderWriterSPI(javax.imageio.spi.ServiceRegistry registry, java.lang.String formatName, boolean isReader)
public static void processOnRegistration(javax.imageio.spi.ServiceRegistry registry, java.lang.Class category, java.lang.String formatName, javax.imageio.spi.ImageReaderWriterSpi spi, int deregisterJvmVersion, int priorityJvmVersion)
public static int readMultiByteInteger(javax.imageio.stream.ImageInputStream iis) throws java.io.IOException
java.io.IOException
Copyright © 2014 Open Microscopy Environment