public class ImageStorage extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ImageStorage.ImageType
An enumeration of supported image types.
|
Modifier and Type | Method and Description |
---|---|
static void |
addImageLoaderFactory(ImageLoaderFactory factory)
Registers an image loader factory.
|
static int |
getNumBands(ImageStorage.ImageType type)
Returns the number of bands for a raw image of the specified type.
|
static ImageFormatDescription[] |
getSupportedDescriptions() |
static ImageFrame[] |
loadAll(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(String input,
ImageLoadListener listener,
int width,
int height,
boolean preserveAspectRatio,
float devPixelScale,
boolean smooth)
Load all images present in the specified input.
|
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(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(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
Copyright © 2020. All rights reserved.