Top Description Inners Fields Constructors Methods
com.sun.javafx.iio

public Class ImageStorage

extends Object
Class Inheritance
Imports
com.sun.javafx.PlatformUtil, com.sun.javafx.iio.ImageFormatDescription.Signature, com.sun.javafx.iio.bmp.BMPImageLoaderFactory, com.sun.javafx.iio.common.ImageTools, com.sun.javafx.iio.gif.GIFImageLoaderFactory, com.sun.javafx.iio.ios.IosImageLoaderFactory, com.sun.javafx.iio.jpeg.JPEGImageLoaderFactory, com.sun.javafx.iio.png.PNGImageLoaderFactory, com.sun.javafx.logging.PlatformLogger, com.sun.javafx.util.DataURI, .Logging, java.io.ByteArrayInputStream, .EOFException, .IOException, .InputStream, .SequenceInputStream, java.util.ArrayList, .HashMap, .Map.Entry

A convenience class for simple image loading. Factories for creating loaders for image formats must be registered with this class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ImageStorage.ImageType

An enumeration of supported image types.

private static class

Field Summary

Modifier and TypeField and Description
private static final boolean
private final ImageLoaderFactory[]
private final HashMap<String, ImageLoaderFactory>
loaderFactoriesByMimeSubtype

A mapping of lower case MIME subtypes to loader factories.

private final HashMap<ImageFormatDescription.Signature, ImageLoaderFactory>
loaderFactoriesBySignature

A mapping of format signature byte sequences to loader factories.

private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addImageLoaderFactory(ImageLoaderFactory
the factory to register.
factory
)

Registers an image loader factory.

public static ImageStorage
private ImageLoader
private synchronized int
public int

Returns:

the number of bands of a raw image of this type
getNumBands
(ImageStorage.ImageType
the type of image
type
)

Returns the number of bands for a raw image of the specified type.

public ImageFormatDescription[]
public ImageFrame[]

Returns:

the sequence of all images in the specified source or null on error.
loadAll
(InputStream
the image data stream.
input
,
ImageLoadListener
a listener to receive notifications about image loading.
listener
,
double
the desired width of the image; if non-positive, the original image width will be used.
width
,
double
the desired height of the image; if non-positive, the original image height will be used.
height
,
boolean
whether to preserve the width-to-height ratio of the image.
preserveAspectRatio
,
float pixelScale, boolean
whether to apply smoothing when downsampling.
smooth
)

Load all images present in the specified stream.

public ImageFrame[]
loadAll(String input, ImageLoadListener listener, double width, double height, boolean preserveAspectRatio, float devPixelScale, boolean smooth)

Load all images present in the specified input.

private ImageFrame[]
loadAll(ImageLoader loader, double width, double height, boolean preserveAspectRatio, float pixelScale, boolean smooth)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isIOSback to summary
private static final boolean isIOS
loaderFactoriesback to summary
private final ImageLoaderFactory[] loaderFactories
loaderFactoriesByMimeSubtypeback to summary
private final HashMap<String, ImageLoaderFactory> loaderFactoriesByMimeSubtype

A mapping of lower case MIME subtypes to loader factories.

loaderFactoriesBySignatureback to summary
private final HashMap<ImageFormatDescription.Signature, ImageLoaderFactory> loaderFactoriesBySignature

A mapping of format signature byte sequences to loader factories.

maxSignatureLengthback to summary
private int maxSignatureLength

Constructor Detail

ImageStorageback to summary
public ImageStorage()

Method Detail

addImageLoaderFactoryback to summary
public void addImageLoaderFactory(ImageLoaderFactory factory)

Registers an image loader factory. The factory replaces any other factory previously registered for the file extensions (converted to lower case), MIME subtype, and signature indicated by the format description.

Parameters
factory:ImageLoaderFactory

the factory to register.

getInstanceback to summary
public static ImageStorage getInstance()
getLoaderBySignatureback to summary
private ImageLoader getLoaderBySignature(InputStream stream, ImageLoadListener listener) throws IOException
getMaxSignatureLengthback to summary
private synchronized int getMaxSignatureLength()
getNumBandsback to summary
public int getNumBands(ImageStorage.ImageType type)

Returns the number of bands for a raw image of the specified type.

Parameters
type:ImageStorage.ImageType

the type of image

Returns:int

the number of bands of a raw image of this type

getSupportedDescriptionsback to summary
public ImageFormatDescription[] getSupportedDescriptions()
loadAllback to summary
public ImageFrame[] loadAll(InputStream input, ImageLoadListener listener, double width, double height, boolean preserveAspectRatio, float pixelScale, boolean smooth) throws ImageStorageException

Load all images present in the specified stream. The image will be rescaled according to this algorithm:

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;
}
Parameters
input:InputStream

the image data stream.

listener:ImageLoadListener

a listener to receive notifications about image loading.

width:double

the desired width of the image; if non-positive, the original image width will be used.

height:double

the desired height of the image; if non-positive, the original image height will be used.

preserveAspectRatio:boolean

whether to preserve the width-to-height ratio of the image.

smooth:boolean

whether to apply smoothing when downsampling.

Returns:ImageFrame[]

the sequence of all images in the specified source or null on error.

loadAllback to summary
public ImageFrame[] loadAll(String input, ImageLoadListener listener, double width, double height, boolean preserveAspectRatio, float devPixelScale, boolean smooth) throws ImageStorageException

Load all images present in the specified input. For more details refer to loadAll(InputStream, ImageLoadListener, double, double, boolean, float, boolean).

loadAllback to summary
private ImageFrame[] loadAll(ImageLoader loader, double width, double height, boolean preserveAspectRatio, float pixelScale, boolean smooth) throws ImageStorageException
com.sun.javafx.iio back to summary

public final Enum ImageStorage.ImageType

extends Enum<ImageStorage.ImageType>
Class Inheritance

An enumeration of supported image types.

Field Summary

Modifier and TypeField and Description
public static final ImageStorage.ImageType
GRAY

An image with a single channel of 8-bit valued gray levels.

public static final ImageStorage.ImageType
GRAY_ALPHA

An image with with two 8-bit valued channels, one of gray levels, the other of non-premultiplied opacity, ordered as GAGAGA...

public static final ImageStorage.ImageType
GRAY_ALPHA_PRE

An image with with two 8-bit valued channels, one of gray levels, the other of premultiplied opacity, ordered as GAGAGA...

public static final ImageStorage.ImageType
PALETTE

An image with with one 8-bit channel of indexes into a 24-bit lookup table which maps the indexes to 8-bit RGB components.

public static final ImageStorage.ImageType
PALETTE_ALPHA

An image with with one 8-bit channel of indexes into a 32-bit lookup table which maps the indexes to 8-bit RGBA components wherein the opacity is not-premultiplied.

public static final ImageStorage.ImageType
PALETTE_ALPHA_PRE

An image with with one 8-bit channel of indexes into a 32-bit lookup table which maps the indexes to 8-bit RGBA components wherein the opacity is premultiplied.

public static final ImageStorage.ImageType
PALETTE_TRANS

An image with with one 8-bit channel of indexes into a 24-bit lookup table which maps the indexes to 8-bit RGB components, and a single transparent index to indicate the location of transparent pixels.

public static final ImageStorage.ImageType
RGB

An image with with three 8-bit valued channels of red, green, and blue, respectively, ordered as RGBRGBRGB...

public static final ImageStorage.ImageType
RGBA

An image with with four 8-bit valued channels of red, green, blue, and non-premultiplied opacity, respectively, ordered as RGBARGBARGBA...

public static final ImageStorage.ImageType
RGBA_PRE

An image with with four 8-bit valued channels of red, green, blue, and premultiplied opacity, respectively, ordered as RGBARGBARGBA...

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ImageStorage.ImageType
public static ImageStorage.ImageType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

GRAYback to summary
public static final ImageStorage.ImageType GRAY

An image with a single channel of 8-bit valued gray levels.

GRAY_ALPHAback to summary
public static final ImageStorage.ImageType GRAY_ALPHA

An image with with two 8-bit valued channels, one of gray levels, the other of non-premultiplied opacity, ordered as GAGAGA...

GRAY_ALPHA_PREback to summary
public static final ImageStorage.ImageType GRAY_ALPHA_PRE

An image with with two 8-bit valued channels, one of gray levels, the other of premultiplied opacity, ordered as GAGAGA...

PALETTEback to summary
public static final ImageStorage.ImageType PALETTE

An image with with one 8-bit channel of indexes into a 24-bit lookup table which maps the indexes to 8-bit RGB components.

PALETTE_ALPHAback to summary
public static final ImageStorage.ImageType PALETTE_ALPHA

An image with with one 8-bit channel of indexes into a 32-bit lookup table which maps the indexes to 8-bit RGBA components wherein the opacity is not-premultiplied.

PALETTE_ALPHA_PREback to summary
public static final ImageStorage.ImageType PALETTE_ALPHA_PRE

An image with with one 8-bit channel of indexes into a 32-bit lookup table which maps the indexes to 8-bit RGBA components wherein the opacity is premultiplied.

PALETTE_TRANSback to summary
public static final ImageStorage.ImageType PALETTE_TRANS

An image with with one 8-bit channel of indexes into a 24-bit lookup table which maps the indexes to 8-bit RGB components, and a single transparent index to indicate the location of transparent pixels.

RGBback to summary
public static final ImageStorage.ImageType RGB

An image with with three 8-bit valued channels of red, green, and blue, respectively, ordered as RGBRGBRGB...

RGBAback to summary
public static final ImageStorage.ImageType RGBA

An image with with four 8-bit valued channels of red, green, blue, and non-premultiplied opacity, respectively, ordered as RGBARGBARGBA...

RGBA_PREback to summary
public static final ImageStorage.ImageType RGBA_PRE

An image with with four 8-bit valued channels of red, green, blue, and premultiplied opacity, respectively, ordered as RGBARGBARGBA...

Constructor Detail

ImageTypeback to summary
private ImageType()

Method Detail

valueOfback to summary
public static ImageStorage.ImageType valueOf(String name)
valuesback to summary
public static ImageStorage.ImageType[] values()
com.sun.javafx.iio back to summary

private Class ImageStorage.InstanceHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final ImageStorage

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final ImageStorage INSTANCE

Constructor Detail

InstanceHolderback to summary
private InstanceHolder()