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

public Class ImageTools

extends Object
Class Inheritance
Imports
com.sun.javafx.geom.Point2D, .Rectangle, com.sun.javafx.iio.ImageFrame, .ImageMetadata, .ImageStorage, .ImageStorage.ImageType, java.io.EOFException, .File, .FileInputStream, .IOException, .InputStream, java.net.URL, java.nio.Buffer, .ByteBuffer

A set of format-independent convenience methods useful in image loading and saving.

Field Summary

Modifier and TypeField and Description
public static final int
PROGRESS_INTERVAL

The percentage increment between progress report updates.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int[]
computeDimensions(int sourceWidth, int sourceHeight, int maxWidth, int maxHeight, boolean preserveAspectRatio)

private static void
computeUpdatedPixels(int sourceOffset, int sourceExtent, int destinationOffset, int dstMin, int dstMax, int sourceSubsampling, int passStart, int passExtent, int passPeriod, int[] vals, int offset)

public static int[]

Returns:

an array of 6 ints containing the destination min X, min Y, width, height, X period and Y period of the region that will be updated.
computeUpdatedPixels
(Rectangle
a Rectangle containing the source region being read, offset by the source subsampling offsets, and clipped against the source bounds, as returned by the getSourceRegion method.
sourceRegion
,
Point2D
a Point containing the coordinates of the upper-left pixel to be written in the destination.
destinationOffset
,
int
the smallest X coordinate (inclusive) of the destination Raster.
dstMinX
,
int
the smallest Y coordinate (inclusive) of the destination Raster.
dstMinY
,
int
the largest X coordinate (inclusive) of the destination Raster.
dstMaxX
,
int
the largest Y coordinate (inclusive) of the destination Raster.
dstMaxY
,
int
the X subsampling factor.
sourceXSubsampling
,
int
the Y subsampling factor.
sourceYSubsampling
,
int
the smallest source X coordinate (inclusive) of the current progressive pass.
passXStart
,
int
the smallest source Y coordinate (inclusive) of the current progressive pass.
passYStart
,
int
the width in pixels of the current progressive pass.
passWidth
,
int
the height in pixels of the current progressive pass.
passHeight
,
int
the X period (horizontal spacing between pixels) of the current progressive pass.
passPeriodX
,
int
the Y period (vertical spacing between pixels) of the current progressive pass.
passPeriodY
)

A utility method that computes the exact set of destination pixels that will be written during a particular decoding pass.

public static byte[]
convert(int width, int height, ImageStorage.ImageType inputType, byte[] input, int inputOffset, int inRowStride, byte[] output, int outputOffset, int outRowStride, byte[][] palette, int transparentIndex, boolean skipTransparent)

public static ImageFrame
public static byte[]
createImageArray(ImageStorage.ImageType type, int width, int height)

public static InputStream
public static ImageStorage.ImageType
public static String
public static int
readFully(InputStream
the stream from which to read the data.
stream
,
byte[]
the buffer into which the data is read.
b
,
int
the start offset of the data.
off
,
int
the number of bytes to read.
len
)

See the general contract of the readFully method of DataInput.

public static int
readFully(InputStream
the stream from which to read the data.
stream
,
byte[]
the buffer into which the data is read.
b
)

See the general contract of the readFully method of DataInput.

public static ByteBuffer
scaleImage(ByteBuffer src, int sourceWidth, int sourceHeight, int numBands, int destWidth, int destHeight, boolean isSmooth)

public static ImageFrame
scaleImageFrame(ImageFrame src, int destWidth, int destHeight, boolean isSmooth)

public static void
skipFully(InputStream
the stream to skip.
stream
,
long
the number of bytes to be skipped.
n
)

Skips over n bytes of data from the input stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PROGRESS_INTERVALback to summary
public static final int PROGRESS_INTERVAL

The percentage increment between progress report updates.

Constructor Detail

ImageToolsback to summary
public ImageTools()

Method Detail

computeDimensionsback to summary
public static int[] computeDimensions(int sourceWidth, int sourceHeight, int maxWidth, int maxHeight, boolean preserveAspectRatio)
computeUpdatedPixelsback to summary
private static void computeUpdatedPixels(int sourceOffset, int sourceExtent, int destinationOffset, int dstMin, int dstMax, int sourceSubsampling, int passStart, int passExtent, int passPeriod, int[] vals, int offset)
computeUpdatedPixelsback to summary
public static int[] computeUpdatedPixels(Rectangle sourceRegion, Point2D destinationOffset, int dstMinX, int dstMinY, int dstMaxX, int dstMaxY, int sourceXSubsampling, int sourceYSubsampling, int passXStart, int passYStart, int passWidth, int passHeight, int passPeriodX, int passPeriodY)

A utility method that computes the exact set of destination pixels that will be written during a particular decoding pass. The intent is to simplify the work done by readers in combining the source region, source subsampling, and destination offset information obtained from the ImageReadParam with the offsets and periods of a progressive or interlaced decoding pass.

Parameters
sourceRegion:Rectangle

a Rectangle containing the source region being read, offset by the source subsampling offsets, and clipped against the source bounds, as returned by the getSourceRegion method.

destinationOffset:Point2D

a Point containing the coordinates of the upper-left pixel to be written in the destination.

dstMinX:int

the smallest X coordinate (inclusive) of the destination Raster.

dstMinY:int

the smallest Y coordinate (inclusive) of the destination Raster.

dstMaxX:int

the largest X coordinate (inclusive) of the destination Raster.

dstMaxY:int

the largest Y coordinate (inclusive) of the destination Raster.

sourceXSubsampling:int

the X subsampling factor.

sourceYSubsampling:int

the Y subsampling factor.

passXStart:int

the smallest source X coordinate (inclusive) of the current progressive pass.

passYStart:int

the smallest source Y coordinate (inclusive) of the current progressive pass.

passWidth:int

the width in pixels of the current progressive pass.

passHeight:int

the height in pixels of the current progressive pass.

passPeriodX:int

the X period (horizontal spacing between pixels) of the current progressive pass.

passPeriodY:int

the Y period (vertical spacing between pixels) of the current progressive pass.

Returns:int[]

an array of 6 ints containing the destination min X, min Y, width, height, X period and Y period of the region that will be updated.

convertback to summary
public static byte[] convert(int width, int height, ImageStorage.ImageType inputType, byte[] input, int inputOffset, int inRowStride, byte[] output, int outputOffset, int outRowStride, byte[][] palette, int transparentIndex, boolean skipTransparent)
convertImageFrameback to summary
public static ImageFrame convertImageFrame(ImageFrame frame)
createImageArrayback to summary
public static byte[] createImageArray(ImageStorage.ImageType type, int width, int height)
createInputStreamback to summary
public static InputStream createInputStream(String input) throws IOException
getConvertedTypeback to summary
public static ImageStorage.ImageType getConvertedType(ImageStorage.ImageType type)
getScaledImageNameback to summary
public static String getScaledImageName(String path)
readFullyback to summary
public static int readFully(InputStream stream, byte[] b, int off, int len) throws IOException

See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the specified input stream.

Parameters
stream:InputStream

the stream from which to read the data.

b:byte[]

the buffer into which the data is read.

off:int

the start offset of the data.

len:int

the number of bytes to read.

Exceptions
IOException:
if another I/O error occurs.
EOFException:
if this input stream reaches the end before reading all the bytes.
readFullyback to summary
public static int readFully(InputStream stream, byte[] b) throws IOException

See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the contained input stream.

Parameters
stream:InputStream

the stream from which to read the data.

b:byte[]

the buffer into which the data is read.

Exceptions
IOException:
if another I/O error occurs.
EOFException:
if this input stream reaches the end before reading all the bytes.
scaleImageback to summary
public static ByteBuffer scaleImage(ByteBuffer src, int sourceWidth, int sourceHeight, int numBands, int destWidth, int destHeight, boolean isSmooth)
scaleImageFrameback to summary
public static ImageFrame scaleImageFrame(ImageFrame src, int destWidth, int destHeight, boolean isSmooth)
skipFullyback to summary
public static void skipFully(InputStream stream, long n) throws IOException

Skips over n bytes of data from the input stream.

Parameters
stream:InputStream

the stream to skip.

n:long

the number of bytes to be skipped.

Exceptions
IOException:
if another I/O error occurs.
EOFException:
if this input stream reaches the end before skipping all the bytes.