|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectImageIOUtilities
public class ImageIOUtilities
Simple class containing commonly used utility methods.
Method Summary | |
---|---|
static String |
adjustAttributeName(String attributeName)
|
static void |
checkNotNull(Object checkMe,
String message)
|
static ColorModel |
createColorModel(SampleModel sampleModel)
Creates a ColorModel that may be used with the
specified SampleModel . |
static void |
displayImageIOMetadata(Node root)
Given a root node, print the values/attributes tree using the System Out |
static boolean |
equals(Object object1,
Object object2)
Convenience method for testing two objects for equality. |
static List<ImageReaderWriterSpi> |
getJDKImageReaderWriterSPI(ServiceRegistry registry,
String formatName,
boolean isReader)
|
static String |
getShortClassName(Object object)
Returns a short class name for the specified object. |
static String |
getShortName(Class<?> classe)
Returns a short class name for the specified class. |
static int |
getSubSamplingFactor2(int xSubsamplingFactor,
int ySubsamplingFactor)
Given a pair of xSubsamplingFactor (xSSF) and ySubsamplingFactor (ySFF), look for a subsampling factor (SSF) in case xSSF ! |
static boolean |
replaceProvider(Class<? extends ImageReaderWriterSpi> providerClass,
String customProviderName,
String originalProviderName,
String format)
Replace the original provider with name originalProviderName with the provider with name customProviderName for the class providerClass and for the provided format . |
static boolean |
sameInterfaces(Class<?> object1,
Class<?> object2,
Class<?> base)
Returns true if the two specified objects implements exactly the
same set of interfaces. |
static void |
setNativeAccelerationAllowed(String operation,
boolean allowed)
Allows or disallow native acceleration for the specified operation on the default JAI instance. |
static void |
setNativeAccelerationAllowed(String operation,
boolean allowed,
JAI jai)
Allows or disallow native acceleration for the specified operation on the given JAI instance. |
static String |
spaces(int length)
Returns a string of the specified length filled with white spaces. |
static File |
urlToFile(URL url)
Takes a URL and converts it to a File. |
static void |
visualize(RenderedImage ri)
base method used to simply visualize RenderedImage without further information |
static void |
visualize(RenderedImage ri,
String title)
base method used to simply visualize RenderedImage |
static void |
visualize(RenderedImage ri,
String title,
boolean rescale)
base method used to visualize RenderedImage by specifying the frame title as well as the request for rescaling. |
static void |
visualize(RenderedImage ri,
String title,
boolean rescale,
int roiThreshold)
base method used to visualize RenderedImage by specifying the frame title as well as the request for rescaling. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final ColorModel createColorModel(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
.
IllegalArgumentException
- If sampleModel
is
null
.public static void displayImageIOMetadata(Node root)
root
- the root node to be printed.public static void visualize(RenderedImage ri)
ri
- RenderedImage to visualizepublic static void visualize(RenderedImage ri, String title)
ri
- RenderedImage to visualizetitle
- title for the frame (usually the image filename)public static void visualize(RenderedImage ri, String title, boolean rescale)
ri
- RenderedImage to visualizetitle
- title for the frame (usually the image filename)rescale
- if true
the RenderedImage will be rescaled
using a default value for the ROI.public static void visualize(RenderedImage ri, String title, boolean rescale, int roiThreshold)
ri
- RenderedImage to visualizetitle
- title for the frame (usually the image filename)rescale
- if true
the RenderedImage will be rescaled
using a default value for the ROI.roiThreshold
- the threshold for the inner ROI. It represent the minimum
value of the pixels representing the region of interest.public static List<ImageReaderWriterSpi> getJDKImageReaderWriterSPI(ServiceRegistry registry, String formatName, boolean isReader)
public static boolean replaceProvider(Class<? extends ImageReaderWriterSpi> providerClass, String customProviderName, String originalProviderName, String format)
providerClass
- the Class
for the providers.customProviderName
- the name of the provider we want to use as new preferred provider.originalProviderName
- the name of the provider we want to deregister.format
- the format for this provi
true
if we find both of the providers and the replacement succeed, false
otherwise.public static boolean equals(Object object1, Object object2)
public static boolean sameInterfaces(Class<?> object1, Class<?> object2, Class<?> base)
true
if the two specified objects implements exactly the
same set of interfaces. Only interfaces assignable to base
are
compared. Declaration order doesn't matter. For example in ISO 19111,
different interfaces exist for different coordinate system geometries (CartesianCS
,
PolarCS
, etc.).
public static String spaces(int length)
length
- The string length. Negative values are clamped to 0.
length
filled with white spaces.public static String getShortName(Class<?> classe)
String
object. It will also name array
according Java language usage, for example "double[]" instead of "[D".
classe
- The object class (may be null
).
public static File urlToFile(URL url)
url
- a URL object that uses protocol "file"
public static int getSubSamplingFactor2(int xSubsamplingFactor, int ySubsamplingFactor)
xSubsamplingFactor
- ySubsamplingFactor
-
public static String getShortClassName(Object object)
String
object.
object
- The object (may be null
).
public static String adjustAttributeName(String attributeName)
public static void setNativeAccelerationAllowed(String operation, boolean allowed, JAI jai)
"Affine"
operation on
an image with float data type, bilinear interpolation and an ImageLayout
rendering hint cause an exception in medialib native code. Disabling the native acceleration
(i.e using the pure Java version) is a convenient workaround until Sun fix the bug.
Implementation note: the current implementation assumes that factories for
native implementations are declared in the com.sun.media.jai.mlib
package, while
factories for pure java implementations are declared in the com.sun.media.jai.opimage
package. It work for Sun's 1.1.2 implementation, but may change in future versions. If this
method doesn't recognize the package, it does nothing.
operation
- The operation name (e.g. "Affine"
).allowed
- false
to disallow native acceleration.jai
- The instance of JAI
we are going to work on. This argument can be
omitted for the default JAI instance.public static void setNativeAccelerationAllowed(String operation, boolean allowed)
setNativeAccelerationAllowed(operation, allowed, JAI.getDefaultInstance())
.
setNativeAccelerationAllowed(String, boolean, JAI)
public static final void checkNotNull(Object checkMe, String message)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |