public class ImageStorage
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ImageStorage.ImageType
An enumeration of supported image types.
|
Modifier and Type | Field and Description |
---|---|
private static boolean |
isIOS |
private static ImageLoaderFactory[] |
loaderFactories |
private static java.util.HashMap<ImageFormatDescription.Signature,ImageLoaderFactory> |
loaderFactoriesBySignature
A mapping of format signature byte sequences to loader factories.
|
private static int |
maxSignatureLength |
Modifier | Constructor and Description |
---|---|
private |
ImageStorage() |
Modifier and Type | Method and Description |
---|---|
static void |
addImageLoaderFactory(ImageLoaderFactory factory)
Registers an image loader factory.
|
private static ImageLoader |
getLoaderBySignature(java.io.InputStream stream,
ImageLoadListener listener) |
private static int |
getMaxSignatureLength() |
static int |
getNumBands(ImageStorage.ImageType type)
Returns the number of bands for a raw image of the specified type.
|
static ImageFormatDescription[] |
getSupportedDescriptions() |
private static ImageFrame[] |
loadAll(ImageLoader loader,
int width,
int height,
boolean preserveAspectRatio,
float pixelScale,
boolean smooth) |
static ImageFrame[] |
loadAll(java.io.InputStream input,
ImageLoadListener listener,
int width,
int height,
boolean preserveAspectRatio,
float pixelScale,
boolean smooth)
Load all images present in the specified stream.
|
static ImageFrame[] |
loadAll(java.lang.String input,
ImageLoadListener listener,
int width,
int height,
boolean preserveAspectRatio,
float devPixelScale,
boolean smooth)
Load all images present in the specified input.
|
private static final java.util.HashMap<ImageFormatDescription.Signature,ImageLoaderFactory> loaderFactoriesBySignature
private static final ImageLoaderFactory[] loaderFactories
private static final boolean isIOS
private static int maxSignatureLength
public static ImageFormatDescription[] getSupportedDescriptions()
public static int getNumBands(ImageStorage.ImageType type)
type
- the type of imagepublic static void addImageLoaderFactory(ImageLoaderFactory factory)
factory
- the factory to register.public static ImageFrame[] loadAll(java.io.InputStream input, ImageLoadListener listener, int width, int height, boolean preserveAspectRatio, float pixelScale, boolean smooth) throws ImageStorageException
int finalWidth, finalHeight; // final dimensions
int width, height; // specified maximum dimensions
// Use source dimensions as default values.
if (width <= 0) {
width = sourceWidth;
}
if (height <= 0) {
height = sourceHeight;
}
// If not downscaling reset the dimensions to those of the source.
if (!((width < sourceWidth && height <= sourceHeight) ||
(width <= sourceWidth && height < sourceHeight))) {
finalWidth = sourceWidth;
finalHeight = sourceHeight;
} else if(preserveAspectRatio) {
double r = (double) sourceWidth / (double) sourceHeight;
finalHeight = (int) ((width / r < height ? width / r : height) + 0.5);
finalWidth = (int) (r * finalHeight + 0.5);
} else {
finalWidth = width;
finalHeight = height;
}
input
- the image data stream.listener
- a listener to receive notifications about image loading.width
- the desired width of the image; if non-positive,
the original image width will be used.height
- the desired height of the image; if non-positive, the
original image height will be used.preserveAspectRatio
- whether to preserve the width-to-height ratio
of the image.smooth
- whether to apply smoothing when downsampling.null
on error.ImageStorageException
public static ImageFrame[] loadAll(java.lang.String input, ImageLoadListener listener, int width, int height, boolean preserveAspectRatio, float devPixelScale, boolean smooth) throws ImageStorageException
#loadAll(java.io.InputStream, com.sun.javafx.iio.ImageLoadListener, int, int, boolean, boolean)
.ImageStorageException
private static int getMaxSignatureLength()
private static ImageFrame[] loadAll(ImageLoader loader, int width, int height, boolean preserveAspectRatio, float pixelScale, boolean smooth) throws ImageStorageException
ImageStorageException
private static ImageLoader getLoaderBySignature(java.io.InputStream stream, ImageLoadListener listener) throws java.io.IOException
java.io.IOException