Top Description Inners Fields Constructors Methods
javafx.scene.image

public abstract Class PixelFormat<T extends Buffer>

extends Object
Class Inheritance
Known Direct Subclasses
javafx.scene.image.PixelFormat.ByteRgb, javafx.scene.image.PixelFormat.IndexedPixelFormat, javafx.scene.image.WritablePixelFormat
Type Parameters
<T>
the type of buffer that stores the pixel data. Only ByteBuffer and IntBuffer are used.
Imports
java.nio.Buffer, .ByteBuffer, .IntBuffer, java.util.Arrays

A PixelFormat object defines the layout of data for a pixel of a given format.
Since
JavaFX 2.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
public static enum
PixelFormat.Type

An enum describing the in-array storage format of a single pixel managed by a PixelFormat.

Field Summary

Modifier and TypeField and Description
private PixelFormat.Type

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static PixelFormat<ByteBuffer>

Returns:

a PixelFormat<ByteBuffer> describing the indicated pixel format with the specified list of non-premultiplied colors
createByteIndexedInstance
(int[]
an int[] array of 32-bit color values in the INT_ARGB format
colors
)

Creates a PixelFormat instance describing a pixel layout with the pixels stored as single bytes representing an index into the specified lookup table of non-premultiplied color values in the INT_ARGB format.

public static PixelFormat<ByteBuffer>

Returns:

a PixelFormat<ByteBuffer> describing the indicated pixel format with the specified list of premultiplied colors
createByteIndexedPremultipliedInstance
(int[]
an int[] array of 32-bit color values in the INT_ARGB_PRE format
colors
)

Creates a PixelFormat instance describing a pixel layout with the pixels stored as single bytes representing an index into the specified lookup table of premultiplied color values in the INT_ARGB_PRE format.

public abstract int

Returns:

a 32-bit value with the color of the pixel in a format similar to the INT_ARGB pixel format
getArgb
(T
the buffer of pixel data
buf
,
int
the X coordinate of the pixel to be read
x
,
int
the Y coordinate of the pixel to be read
y
,
int
the number of buffer elements between the start of adjacent pixel rows in the buffer
scanlineStride
)

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format.

public static WritablePixelFormat<ByteBuffer>

Returns:

a WritablePixelFormat<ByteBuffer> describing the indicated pixel format
getByteBgraInstance
()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the non-premultiplied components stored in order of increasing index: blue, green, red, alpha.

public static WritablePixelFormat<ByteBuffer>

Returns:

a WritablePixelFormat<ByteBuffer> describing the indicated pixel format
getByteBgraPreInstance
()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the premultiplied components stored in order of increasing index: blue, green, red, alpha.

public static PixelFormat<ByteBuffer>

Returns:

a PixelFormat<ByteBuffer> describing the indicated pixel format
getByteRgbInstance
()

Returns a PixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the color components stored in order of increasing index: red, green, blue.

public static WritablePixelFormat<IntBuffer>

Returns:

a WritabelPixelFormat<IntBuffer> describing the indicated pixel format
getIntArgbInstance
()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in 32-bit integers with the non-premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

public static WritablePixelFormat<IntBuffer>

Returns:

a WritabelPixelFormat<IntBuffer> describing the indicated pixel format
getIntArgbPreInstance
()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in 32-bit integers with the premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

public PixelFormat.Type

Returns:

the Type enum of the pixels
getType
()

Returns the enum representing the storage format of the pixels managed by this PixelFormat object.

public abstract boolean

Returns:

true iff the managed color components are premultiplied by alpha
isPremultiplied
()

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

public abstract boolean

Returns:

true iff this PixelFormat can convert colors to pixel data
isWritable
()

Returns true iff this PixelFormat object can convert color information into a pixel representation.

pack-priv static int
NonPretoPre(int nonpre)

pack-priv static int
PretoNonPre(int pre)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

typeback to summary
private PixelFormat.Type type

Constructor Detail

PixelFormatback to summary
pack-priv PixelFormat(PixelFormat.Type type)

Method Detail

createByteIndexedInstanceback to summary
public static PixelFormat<ByteBuffer> createByteIndexedInstance(int[] colors)

Creates a PixelFormat instance describing a pixel layout with the pixels stored as single bytes representing an index into the specified lookup table of non-premultiplied color values in the INT_ARGB format.

Pixels in this format can be decoded using the following sample code:

int pixel = array[rowstart + x] & 0xff;
    int argb  = colors[pixel];

    int alpha = ((argb >> 24) & 0xff);
    int red   = ((argb >> 16) & 0xff);
    int green = ((argb >>  8) & 0xff);
    int blue  = ((argb      ) & 0xff);
Parameters
colors:int[]

an int[] array of 32-bit color values in the INT_ARGB format

Returns:PixelFormat<ByteBuffer>

a PixelFormat<ByteBuffer> describing the indicated pixel format with the specified list of non-premultiplied colors

createByteIndexedPremultipliedInstanceback to summary
public static PixelFormat<ByteBuffer> createByteIndexedPremultipliedInstance(int[] colors)

Creates a PixelFormat instance describing a pixel layout with the pixels stored as single bytes representing an index into the specified lookup table of premultiplied color values in the INT_ARGB_PRE format.

Pixels in this format can be decoded using the following sample code:

int pixel = array[rowstart + x] & 0xff;
    int argb  = colors[pixel];

    int alpha = ((argb >> 24) & 0xff);
    int red   = ((argb >> 16) & 0xff);
    int green = ((argb >>  8) & 0xff);
    int blue  = ((argb      ) & 0xff);
Parameters
colors:int[]

an int[] array of 32-bit color values in the INT_ARGB_PRE format

Returns:PixelFormat<ByteBuffer>

a PixelFormat<ByteBuffer> describing the indicated pixel format with the specified list of premultiplied colors

getArgbback to summary
public abstract int getArgb(T buf, int x, int y, int scanlineStride)

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format. The 32-bit integer will contain the 4 color components in separate 8-bit fields in ARGB order from the most significant byte to the least significant byte. The buffer should be positioned to the start of the pixel data such that buf.get(0) would return the pixel information for the pixel at coordinates (0, 0). The scanlineStride parameter defines the distance from the pixel data at the start of one row to the pixel data at the start of the immediately following row at the next higher Y coordinate. Usually, scanlineStride is the same as the width of the image multiplied by the number of data elements per pixel (1 for the case of the integer and indexed formats, or 3 or 4 in the case of the byte formats), but some images may have further padding between rows for alignment or other purposes.

The color components can be extracted from the returned integer using the following sample code:

    int alpha = ((retval >> 24) & 0xff);
    int red   = ((retval >> 16) & 0xff);
    int green = ((retval >>  8) & 0xff);
    int blue  = ((retval      ) & 0xff);
Parameters
buf:T

the buffer of pixel data

x:int

the X coordinate of the pixel to be read

y:int

the Y coordinate of the pixel to be read

scanlineStride:int

the number of buffer elements between the start of adjacent pixel rows in the buffer

Returns:int

a 32-bit value with the color of the pixel in a format similar to the INT_ARGB pixel format

getByteBgraInstanceback to summary
public static WritablePixelFormat<ByteBuffer> getByteBgraInstance()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the non-premultiplied components stored in order of increasing index: blue, green, red, alpha.

Pixels in this format can be decoded using the following sample code:

int i = rowstart + x * 4;

    int blue  = (array[i+0] & 0xff);
    int green = (array[i+1] & 0xff);
    int red   = (array[i+2] & 0xff);
    int alpha = (array[i+3] & 0xff);
Returns:WritablePixelFormat<ByteBuffer>

a WritablePixelFormat<ByteBuffer> describing the indicated pixel format

getByteBgraPreInstanceback to summary
public static WritablePixelFormat<ByteBuffer> getByteBgraPreInstance()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the premultiplied components stored in order of increasing index: blue, green, red, alpha.

Pixels in this format can be decoded using the following sample code:

int i = rowstart + x * 4;

    int blue  = (array[i+0] & 0xff);
    int green = (array[i+1] & 0xff);
    int red   = (array[i+2] & 0xff);
    int alpha = (array[i+3] & 0xff);
Returns:WritablePixelFormat<ByteBuffer>

a WritablePixelFormat<ByteBuffer> describing the indicated pixel format

getByteRgbInstanceback to summary
public static PixelFormat<ByteBuffer> getByteRgbInstance()

Returns a PixelFormat instance describing a pixel layout with the pixels stored in adjacent bytes with the color components stored in order of increasing index: red, green, blue.

Pixels in this format can be decoded using the following sample code:

int i = rowstart + x * 3;

    int red   = (array[i+0] & 0xff);
    int green = (array[i+1] & 0xff);
    int blue  = (array[i+2] & 0xff);
Returns:PixelFormat<ByteBuffer>

a PixelFormat<ByteBuffer> describing the indicated pixel format

getIntArgbInstanceback to summary
public static WritablePixelFormat<IntBuffer> getIntArgbInstance()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in 32-bit integers with the non-premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

Pixels in this format can be decoded using the following sample code:

int pixel = array[rowstart + x];

    int alpha = ((pixel >> 24) & 0xff);
    int red   = ((pixel >> 16) & 0xff);
    int green = ((pixel >>  8) & 0xff);
    int blue  = ((pixel >>   ) & 0xff);
Returns:WritablePixelFormat<IntBuffer>

a WritabelPixelFormat<IntBuffer> describing the indicated pixel format

getIntArgbPreInstanceback to summary
public static WritablePixelFormat<IntBuffer> getIntArgbPreInstance()

Returns a WritablePixelFormat instance describing a pixel layout with the pixels stored in 32-bit integers with the premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

Pixels in this format can be decoded using the following sample code:

int pixel = array[rowstart + x];

    int alpha = ((pixel >> 24) & 0xff);
    int red   = ((pixel >> 16) & 0xff);
    int green = ((pixel >>  8) & 0xff);
    int blue  = ((pixel >>   ) & 0xff);
Returns:WritablePixelFormat<IntBuffer>

a WritabelPixelFormat<IntBuffer> describing the indicated pixel format

getTypeback to summary
public PixelFormat.Type getType()

Returns the enum representing the storage format of the pixels managed by this PixelFormat object.

Returns:PixelFormat.Type

the Type enum of the pixels

isPremultipliedback to summary
public abstract boolean isPremultiplied()

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

Returns:boolean

true iff the managed color components are premultiplied by alpha

isWritableback to summary
public abstract boolean isWritable()

Returns true iff this PixelFormat object can convert color information into a pixel representation.

Returns:boolean

true iff this PixelFormat can convert colors to pixel data

NonPretoPreback to summary
pack-priv static int NonPretoPre(int nonpre)
PretoNonPreback to summary
pack-priv static int PretoNonPre(int pre)
javafx.scene.image back to summary

pack-priv Class PixelFormat.ByteRgb

extends PixelFormat<ByteBuffer>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final PixelFormat.ByteRgb

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
getArgb(ByteBuffer buf, int x, int y, int scanlineStride)

Implements abstract javafx.scene.image.PixelFormat.getArgb.

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format.

public boolean
isPremultiplied()

Implements abstract javafx.scene.image.PixelFormat.isPremultiplied.

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

public boolean
isWritable()

Implements abstract javafx.scene.image.PixelFormat.isWritable.

Returns true iff this PixelFormat object can convert color information into a pixel representation.

Inherited from javafx.scene.image.PixelFormat:
createByteIndexedInstancecreateByteIndexedPremultipliedInstancegetByteBgraInstancegetByteBgraPreInstancegetByteRgbInstancegetIntArgbInstancegetIntArgbPreInstancegetTypeNonPretoPrePretoNonPre

Field Detail

instanceback to summary
pack-priv static final PixelFormat.ByteRgb instance

Constructor Detail

ByteRgbback to summary
private ByteRgb()

Method Detail

getArgbback to summary
public int getArgb(ByteBuffer buf, int x, int y, int scanlineStride)

Implements abstract javafx.scene.image.PixelFormat.getArgb.

Doc from javafx.scene.image.PixelFormat.getArgb.

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format. The 32-bit integer will contain the 4 color components in separate 8-bit fields in ARGB order from the most significant byte to the least significant byte. The buffer should be positioned to the start of the pixel data such that buf.get(0) would return the pixel information for the pixel at coordinates (0, 0). The scanlineStride parameter defines the distance from the pixel data at the start of one row to the pixel data at the start of the immediately following row at the next higher Y coordinate. Usually, scanlineStride is the same as the width of the image multiplied by the number of data elements per pixel (1 for the case of the integer and indexed formats, or 3 or 4 in the case of the byte formats), but some images may have further padding between rows for alignment or other purposes.

The color components can be extracted from the returned integer using the following sample code:

    int alpha = ((retval >> 24) & 0xff);
    int red   = ((retval >> 16) & 0xff);
    int green = ((retval >>  8) & 0xff);
    int blue  = ((retval      ) & 0xff);
Annotations
@Override
isPremultipliedback to summary
public boolean isPremultiplied()

Implements abstract javafx.scene.image.PixelFormat.isPremultiplied.

Doc from javafx.scene.image.PixelFormat.isPremultiplied.

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements abstract javafx.scene.image.PixelFormat.isWritable.

Doc from javafx.scene.image.PixelFormat.isWritable.

Returns true iff this PixelFormat object can convert color information into a pixel representation.

Annotations
@Override
javafx.scene.image back to summary

pack-priv Class PixelFormat.IndexedPixelFormat

extends PixelFormat<ByteBuffer>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int[]
pack-priv int[]
pack-priv boolean

Constructor Summary

AccessConstructor and Description
private
IndexedPixelFormat(PixelFormat.Type type, boolean premult, int[] colors)

Method Summary

Modifier and TypeMethod and Description
pack-priv static PixelFormat<T extends Buffer>
createByte(int[] colors, boolean premult)

public int
getArgb(ByteBuffer buf, int x, int y, int scanlineStride)

Implements abstract javafx.scene.image.PixelFormat.getArgb.

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format.

pack-priv int[]
pack-priv int[]
public boolean
isPremultiplied()

Implements abstract javafx.scene.image.PixelFormat.isPremultiplied.

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

public boolean
isWritable()

Implements abstract javafx.scene.image.PixelFormat.isWritable.

Returns true iff this PixelFormat object can convert color information into a pixel representation.

Inherited from javafx.scene.image.PixelFormat:
createByteIndexedInstancecreateByteIndexedPremultipliedInstancegetByteBgraInstancegetByteBgraPreInstancegetByteRgbInstancegetIntArgbInstancegetIntArgbPreInstancegetTypeNonPretoPrePretoNonPre

Field Detail

nonprecolorsback to summary
pack-priv int[] nonprecolors
precolorsback to summary
pack-priv int[] precolors
premultback to summary
pack-priv boolean premult

Constructor Detail

IndexedPixelFormatback to summary
private IndexedPixelFormat(PixelFormat.Type type, boolean premult, int[] colors)

Method Detail

createByteback to summary
pack-priv static PixelFormat<T extends Buffer> createByte(int[] colors, boolean premult)
getArgbback to summary
public int getArgb(ByteBuffer buf, int x, int y, int scanlineStride)

Implements abstract javafx.scene.image.PixelFormat.getArgb.

Doc from javafx.scene.image.PixelFormat.getArgb.

Reads pixel data from the buffer at the specified coordinates and converts it to a 32-bit integer representation of the color in the INT_ARGB format. The 32-bit integer will contain the 4 color components in separate 8-bit fields in ARGB order from the most significant byte to the least significant byte. The buffer should be positioned to the start of the pixel data such that buf.get(0) would return the pixel information for the pixel at coordinates (0, 0). The scanlineStride parameter defines the distance from the pixel data at the start of one row to the pixel data at the start of the immediately following row at the next higher Y coordinate. Usually, scanlineStride is the same as the width of the image multiplied by the number of data elements per pixel (1 for the case of the integer and indexed formats, or 3 or 4 in the case of the byte formats), but some images may have further padding between rows for alignment or other purposes.

The color components can be extracted from the returned integer using the following sample code:

    int alpha = ((retval >> 24) & 0xff);
    int red   = ((retval >> 16) & 0xff);
    int green = ((retval >>  8) & 0xff);
    int blue  = ((retval      ) & 0xff);
Annotations
@Override
getNonPreColorsback to summary
pack-priv int[] getNonPreColors()
getPreColorsback to summary
pack-priv int[] getPreColors()
isPremultipliedback to summary
public boolean isPremultiplied()

Implements abstract javafx.scene.image.PixelFormat.isPremultiplied.

Doc from javafx.scene.image.PixelFormat.isPremultiplied.

Returns true iff the color components decoded (or encoded) by this format are pre-multiplied by the alpha component for more efficient blending calculations.

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements abstract javafx.scene.image.PixelFormat.isWritable.

Doc from javafx.scene.image.PixelFormat.isWritable.

Returns true iff this PixelFormat object can convert color information into a pixel representation.

Annotations
@Override
javafx.scene.image back to summary

public final Enum PixelFormat.Type

extends Enum<PixelFormat.Type>
Class Inheritance

An enum describing the in-array storage format of a single pixel managed by a PixelFormat.
Since
JavaFX 2.2

Field Summary

Modifier and TypeField and Description
public static final PixelFormat.Type
BYTE_BGRA

The pixels are stored in adjacent bytes with the non-premultiplied components stored in order of increasing index: blue, green, red, alpha.

public static final PixelFormat.Type
BYTE_BGRA_PRE

The pixels are stored in adjacent bytes with the premultiplied components stored in order of increasing index: blue, green, red, alpha.

public static final PixelFormat.Type
BYTE_INDEXED

The pixel colors are referenced by byte indices stored in the pixel array, with the byte interpreted as an unsigned index into a list of colors provided by the PixelFormat object.

public static final PixelFormat.Type
BYTE_RGB

The opaque pixels are stored in adjacent bytes with the color components stored in order of increasing index: red, green, blue.

public static final PixelFormat.Type
INT_ARGB

The pixels are stored in 32-bit integers with the non-premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

public static final PixelFormat.Type
INT_ARGB_PRE

The pixels are stored in 32-bit integers with the premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

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

Field Detail

BYTE_BGRAback to summary
public static final PixelFormat.Type BYTE_BGRA

The pixels are stored in adjacent bytes with the non-premultiplied components stored in order of increasing index: blue, green, red, alpha.

BYTE_BGRA_PREback to summary
public static final PixelFormat.Type BYTE_BGRA_PRE

The pixels are stored in adjacent bytes with the premultiplied components stored in order of increasing index: blue, green, red, alpha.

BYTE_INDEXEDback to summary
public static final PixelFormat.Type BYTE_INDEXED

The pixel colors are referenced by byte indices stored in the pixel array, with the byte interpreted as an unsigned index into a list of colors provided by the PixelFormat object.

BYTE_RGBback to summary
public static final PixelFormat.Type BYTE_RGB

The opaque pixels are stored in adjacent bytes with the color components stored in order of increasing index: red, green, blue.

INT_ARGBback to summary
public static final PixelFormat.Type INT_ARGB

The pixels are stored in 32-bit integers with the non-premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

INT_ARGB_PREback to summary
public static final PixelFormat.Type INT_ARGB_PRE

The pixels are stored in 32-bit integers with the premultiplied components stored in order, from MSb to LSb: alpha, red, green, blue.

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static PixelFormat.Type valueOf(String name)
valuesback to summary
public static PixelFormat.Type[] values()