public final class ImageUtilities extends Object
Do not rely on this API!
It may change in incompatible way in any future version.
Modifier and Type | Field and Description |
---|---|
static RenderingHints |
BORDER_EXTENDER_HINTS |
static BorderExtender |
DEFAULT_BORDER_EXTENDER |
static String |
DIRECT_KAKADU_PLUGIN |
static RenderingHints |
DONT_REPLACE_INDEX_COLOR_MODEL
|
static RenderingHints |
EXTEND_BORDER_BY_COPYING
Cached instance of a
RenderingHints for controlling border extension on JAI
operations. |
static RenderingHints |
EXTEND_BORDER_BY_REFLECT
Cached instance of a
RenderingHints for controlling border extension on JAI
operations. |
static String[] |
INTERPOLATION_NAMES
List of valid names.
|
static int[] |
INTERPOLATION_TYPES
Interpolation types (provided by Java Advanced Imaging) for
INTERPOLATION_NAMES . |
static RenderingHints |
NN_INTERPOLATION_HINT
RenderingHints for requesting Nearest Neighbor intepolation. |
static RenderingHints |
NOCACHE_HINT
|
static float |
RATIONAL_TOLERANCE |
static RenderingHints |
REPLACE_INDEX_COLOR_MODEL
|
static double[][] |
RGB_TO_GRAY_MATRIX |
static double[][] |
RGBA_TO_GRAY_MATRIX |
Modifier and Type | Method and Description |
---|---|
static RenderedImage |
applyRescaling(Double[] scales,
Double[] offsets,
RenderedImage image,
Hints hints)
Applies values rescaling if either the scales or the offsets array is non null, or has any
value that is not a default (1 for scales, 0 for offsets)
|
static boolean |
checkEmptySourceRegion(ImageReadParam readParameters,
Rectangle dimensions)
Checks that the provided
dimensions when intersected with the source region used
by the provided ImageReadParam instance does not result in an empty Rectangle . |
static ImageReadParam |
cloneImageReadParam(ImageReadParam param) |
static ImageLayout |
createIntersection(ImageLayout layout,
List<RenderedImage> sources)
Computes a new
ImageLayout which is the intersection of the specified ImageLayout and all RenderedImage s in the supplied list. |
static void |
disposeImage(RenderedImage inputImage)
Allow to dispose this image, as well as the related image sources, readers, stream, ROI.
|
static void |
disposePlanarImageChain(PlanarImage pi)
Dispose an image with all its ancestors.
|
static void |
disposeSinglePlanarImage(PlanarImage planarImage)
Disposes the specified image, without recursing back in the sources
|
static void |
fill(WritableRenderedImage image,
Number value)
Sets every samples in the given image to the given value.
|
static Number[] |
getBackgroundValues(SampleModel sampleModel,
double[] backgroundValues)
Build a background values array using the same dataType of the input
SampleModel (if
available) and the values provided in the input array. |
static String |
getDatabufferTypeName(int dataType)
Transform a data type into a representative
String . |
static Rectangle |
getDimension(int imageIndex,
ImageInputStream inStream,
ImageReader reader)
Retrieves the dimensions of the
RenderedImage at index imageIndex for
the provided ImageReader and ImageInputStream . |
static ImageLayout |
getImageLayout(RenderedImage image)
Suggests an
ImageLayout for the specified image. |
static String |
getInterpolationName(Interpolation interp)
Returns the interpolation name for the specified interpolation object.
|
static ReferencedEnvelope |
getReferencedEnvelopeFromGeographicBoundingBox(GeographicBoundingBox geographicBBox)
Builds a
ReferencedEnvelope from a GeographicBoundingBox . |
static RenderingHints |
getRenderingHints(RenderedImage image)
Suggests a set of
RenderingHints for the specified image. |
static ReferencedEnvelope |
getWGS84ReferencedEnvelope(GeneralEnvelope coverageEnvelope)
Builds a
ReferencedEnvelope in WGS84 from a GeneralEnvelope . |
static boolean |
isMediaLibAvailable()
Tells me whether or not the native libraries for JAI are active or not.
|
static Rectangle2D |
layoutHelper(RenderedImage source,
float scaleX,
float scaleY,
float transX,
float transY,
Interpolation interp) |
static RenderedImage |
maskColor(Color transparentColor,
RenderedImage image)
Relies on the
ImageWorker to mask a certain color from an image. |
static RenderedOp |
tileImage(RenderedOp image)
Tiles the specified image.
|
static Interpolation |
toInterpolation(Object type)
Casts the specified object to an
object . |
static Dimension |
toTileSize(Dimension size)
Suggests a tile size for the specified image size.
|
public static final double[][] RGB_TO_GRAY_MATRIX
public static final double[][] RGBA_TO_GRAY_MATRIX
public static final RenderingHints DONT_REPLACE_INDEX_COLOR_MODEL
public static final RenderingHints REPLACE_INDEX_COLOR_MODEL
public static final RenderingHints NN_INTERPOLATION_HINT
RenderingHints
for requesting Nearest Neighbor intepolation.public static final RenderingHints NOCACHE_HINT
public static final RenderingHints EXTEND_BORDER_BY_COPYING
RenderingHints
for controlling border extension on JAI
operations. It contains an instance of a BorderExtenderCopy
.public static final RenderingHints EXTEND_BORDER_BY_REFLECT
RenderingHints
for controlling border extension on JAI
operations. It contains an instance of a BorderExtenderReflect
.public static final String[] INTERPOLATION_NAMES
public static final int[] INTERPOLATION_TYPES
INTERPOLATION_NAMES
.public static final BorderExtender DEFAULT_BORDER_EXTENDER
public static final RenderingHints BORDER_EXTENDER_HINTS
public static final String DIRECT_KAKADU_PLUGIN
public static final float RATIONAL_TOLERANCE
public static ImageLayout getImageLayout(RenderedImage image)
ImageLayout
for the specified image. All parameters are initially set
equal to those of the given RenderedImage
, and then the tile
size is updated according the image size. This method never returns null
.public static RenderingHints getRenderingHints(RenderedImage image)
RenderingHints
for the specified image. The rendering hints may
include the following parameters:
JAI.KEY_IMAGE_LAYOUT
with a proposed tile size.
null
if no rendering hints is proposed.public static Dimension toTileSize(Dimension size)
size
is the image's
size. On output, it is the tile size. This method write the result directly in the supplied
object and returns size
for convenience.
This method it aimed to computing a tile size such that the tile grid would have
overlapped the image bound in order to avoid having tiles crossing the image bounds and being
therefore partially empty. This method will never returns a tile size smaller than . If this method can't suggest a size, then it left the
corresponding size
field (width
or height
) unchanged.
The width
and height
fields are processed
independently in the same way. The following discussion use the width
field as an
example.
This method inspects different tile sizes close to the default tile size. Lets width
be the default tile width.
Values are tried in the following order: width
, width+1
, width-1
,
width+2
, width-2
, width+3
, width-3
, etc. until
one of the following happen:
Dimension
field (width
or height
) is set to this value.
Dimension
field to a value that
maximize the remainder of image size / tile size (in other words,
the size that left as few empty pixels as possible).
public static ImageLayout createIntersection(ImageLayout layout, List<RenderedImage> sources)
ImageLayout
which is the intersection of the specified ImageLayout
and all RenderedImage
s in the supplied list. If the minX
, minY
, width
and height
properties are not defined in the layout
, then they will be inherited from the first source for consistency
with OpImage
constructor.layout
- The original layout. This object will not be modified.sources
- The list of sources RenderedImage
.ImageLayout
, or the original layout
if no change was needed.public static Interpolation toInterpolation(Object type) throws IllegalArgumentException
object
.type
- The interpolation type as an Interpolation
or a CharSequence
object.IllegalArgumentException
- if the specified interpolation type is not a know one.public static String getInterpolationName(Interpolation interp)
interp
- The interpolation object, or null
for "nearest" (which is an other way
to say "no interpolation").public static RenderedOp tileImage(RenderedOp image) throws IOException
IOException
- If an I/O operation were required (in order to check if the image were
tiled on disk) and failed.public static void fill(WritableRenderedImage image, Number value)
image
- The image to fill.value
- The value to to given to every samples.public static boolean isMediaLibAvailable()
false
in case the JAI native libs are not in the path, true
otherwise.public static void disposePlanarImageChain(PlanarImage pi)
pi
- the PlanarImage
to dispose.public static RenderedImage maskColor(Color transparentColor, RenderedImage image) throws IllegalStateException
ImageWorker
to mask a certain color from an image.transparentColor
- the Color
to make transparentimage
- the RenderedImage
to work onRenderedImage
where the provided Color
has turned into
transparent.IllegalStateException
public static ImageReadParam cloneImageReadParam(ImageReadParam param)
public static Rectangle2D layoutHelper(RenderedImage source, float scaleX, float scaleY, float transX, float transY, Interpolation interp)
public static ReferencedEnvelope getReferencedEnvelopeFromGeographicBoundingBox(GeographicBoundingBox geographicBBox)
ReferencedEnvelope
from a GeographicBoundingBox
. This is useful in
order to have an implementation of BoundingBox
from a GeographicBoundingBox
which strangely does implement GeographicBoundingBox
.geographicBBox
- the GeographicBoundingBox
to convert.ReferencedEnvelope
.public static ReferencedEnvelope getWGS84ReferencedEnvelope(GeneralEnvelope coverageEnvelope)
ReferencedEnvelope
in WGS84 from a GeneralEnvelope
.coverageEnvelope
- the GeneralEnvelope
to convert.ReferencedEnvelope
in WGS84 or null
in case a
problem during the conversion occurs.public static Rectangle getDimension(int imageIndex, ImageInputStream inStream, ImageReader reader) throws IOException
RenderedImage
at index imageIndex
for
the provided ImageReader
and ImageInputStream
.
Notice that none of the input parameters can be null
or a NullPointerException
will be thrown. Morevoer the imageIndex
cannot be negative
or an IllegalArgumentException
will be thrown.
imageIndex
- the index of the image to get the dimensions for.inStream
- the ImageInputStream
to use as an inputreader
- the ImageReader
to decode the image dimensions.Rectangle
that contains the dimensions for the image at index
imageIndex
IOException
- in case the ImageReader
or the ImageInputStream
fail.public static final boolean checkEmptySourceRegion(ImageReadParam readParameters, Rectangle dimensions)
dimensions
when intersected with the source region used
by the provided ImageReadParam
instance does not result in an empty Rectangle
.
Input parameters cannot be null.
readParameters
- an instance of ImageReadParam
for which we want to check the
source region element.dimensions
- an instance of Rectangle
to use for the check.true
if the intersection is not empty, false
otherwise.public static Number[] getBackgroundValues(SampleModel sampleModel, double[] backgroundValues)
SampleModel
(if
available) and the values provided in the input array.public static void disposeImage(RenderedImage inputImage)
inputImage
- the image to be disposed.public static void disposeSinglePlanarImage(PlanarImage planarImage)
public static String getDatabufferTypeName(int dataType)
String
.String
.public static RenderedImage applyRescaling(Double[] scales, Double[] offsets, RenderedImage image, Hints hints)
scales
- The scales arrayoffsets
- The offsets arrayimage
- The image to be rescaledhints
- The image processing hints, if any (can be null)Copyright © 1996–2023 Geotools. All rights reserved.