Top Description Methods
javafx.scene.image

public Interface PixelReader

Imports
java.nio.Buffer, .ByteBuffer, .IntBuffer, javafx.scene.paint.Color

This interface defines methods for retrieving the pixel data from an Image or other surface containing pixels.
Since
JavaFX 2.2

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

a 32-bit representation of the color in the format described by the INT_ARGB PixelFormat type.
getArgb
(int
the X coordinate of the pixel color to read
x
,
int
the Y coordinate of the pixel color to read
y
)

Reads a 32-bit integer representation of the color of a pixel from the specified coordinates in the surface.

public Color

Returns:

the Color object representing the color of the indicated pixel
getColor
(int
the X coordinate of the pixel color to read
x
,
int
the Y coordinate of the pixel color to read
y
)

Reads the color of a pixel from the specified coordinates in the surface and returns the value as a Color object.

public PixelFormat<T extends Buffer>

Returns:

the PixelFormat that best describes the underlying pixels
getPixelFormat
()

This method returns the PixelFormat in which the surface stores its pixels, or a roughly equivalent pixel format into which it can easily convert its pixels for purposes of reading them.

public <
the type of the buffer
T extends Buffer
>
void
getPixels(int
the X coordinate of the rectangular region to read
x
,
int
the Y coordinate of the rectangular region to read
y
,
int
the width of the rectangular region to read
w
,
int
the height of the rectangular region to read
h
,
WritablePixelFormat<T>
the PixelFormat object defining the format to store the pixels into buffer
pixelformat
,
T
a buffer of a type appropriate for the indicated PixelFormat object
buffer
,
int
the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data.
scanlineStride
)

Reads pixel data from a rectangular region of the surface into the specified buffer.

public void
getPixels(int
the X coordinate of the rectangular region to read
x
,
int
the Y coordinate of the rectangular region to read
y
,
int
the width of the rectangular region to read
w
,
int
the height of the rectangular region to read
h
,
WritablePixelFormat<ByteBuffer>
the PixelFormat<ByteBuffer> object defining the byte format to store the pixels into buffer
pixelformat
,
byte[]
a byte array to store the returned pixel data
buffer
,
int
the offset into buffer to store the first pixel data
offset
,
int
the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data
scanlineStride
)

Reads pixel data from a rectangular region of the surface into the specified byte array.

public void
getPixels(int
the X coordinate of the rectangular region to read
x
,
int
the Y coordinate of the rectangular region to read
y
,
int
the width of the rectangular region to read
w
,
int
the height of the rectangular region to read
h
,
WritablePixelFormat<IntBuffer>
the PixelFormat<IntBuffer> object defining the int format to store the pixels into buffer
pixelformat
,
int[]
a int array to store the returned pixel data
buffer
,
int
the offset into buffer to store the first pixel data
offset
,
int
the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data
scanlineStride
)

Reads pixel data from a rectangular region of the surface into the specified int array.

Method Detail

getArgbback to summary
public int getArgb(int x, int y)

Reads a 32-bit integer representation of the color of a pixel from the specified coordinates in the surface. 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.

Parameters
x:int

the X coordinate of the pixel color to read

y:int

the Y coordinate of the pixel color to read

Returns:int

a 32-bit representation of the color in the format described by the INT_ARGB PixelFormat type.

getColorback to summary
public Color getColor(int x, int y)

Reads the color of a pixel from the specified coordinates in the surface and returns the value as a Color object.

Parameters
x:int

the X coordinate of the pixel color to read

y:int

the Y coordinate of the pixel color to read

Returns:Color

the Color object representing the color of the indicated pixel

getPixelFormatback to summary
public PixelFormat<T extends Buffer> getPixelFormat()

This method returns the PixelFormat in which the surface stores its pixels, or a roughly equivalent pixel format into which it can easily convert its pixels for purposes of reading them.

Returns:PixelFormat<T extends Buffer>

the PixelFormat that best describes the underlying pixels

getPixelsback to summary
public <T extends Buffer> void getPixels(int x, int y, int w, int h, WritablePixelFormat<T> pixelformat, T buffer, int scanlineStride)

Reads pixel data from a rectangular region of the surface into the specified buffer. The format to be used for pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data in the indicated format. The buffer is assumed to be positioned to the location where the first pixel data from the image pixel at location (x, y) will be stored. Pixel data for a row will be stored in adjacent locations within the buffer packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be stored offset from each other by the number of buffer data elements defined by scanlineStride.

Parameters
<T>
the type of the buffer
x:int

the X coordinate of the rectangular region to read

y:int

the Y coordinate of the rectangular region to read

w:int

the width of the rectangular region to read

h:int

the height of the rectangular region to read

pixelformat:WritablePixelFormat<T>

the PixelFormat object defining the format to store the pixels into buffer

buffer:T

a buffer of a type appropriate for the indicated PixelFormat object

scanlineStride:int

the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data.

getPixelsback to summary
public void getPixels(int x, int y, int w, int h, WritablePixelFormat<ByteBuffer> pixelformat, byte[] buffer, int offset, int scanlineStride)

Reads pixel data from a rectangular region of the surface into the specified byte array. The format to be used for pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data in the indicated format. The pixelformat must be a compatible PixelFormat<ByteBuffer> type. The data for the first pixel at location (x, y) will be read into the array index specified by the offset parameter. Pixel data for a row will be stored in adjacent locations within the array packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be stored offset from each other by the number of byte array elements defined by scanlineStride.

Parameters
x:int

the X coordinate of the rectangular region to read

y:int

the Y coordinate of the rectangular region to read

w:int

the width of the rectangular region to read

h:int

the height of the rectangular region to read

pixelformat:WritablePixelFormat<ByteBuffer>

the PixelFormat<ByteBuffer> object defining the byte format to store the pixels into buffer

buffer:byte[]

a byte array to store the returned pixel data

offset:int

the offset into buffer to store the first pixel data

scanlineStride:int

the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data

getPixelsback to summary
public void getPixels(int x, int y, int w, int h, WritablePixelFormat<IntBuffer> pixelformat, int[] buffer, int offset, int scanlineStride)

Reads pixel data from a rectangular region of the surface into the specified int array. The format to be used for pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data in the indicated format. The pixelformat must be a compatible PixelFormat<IntBuffer> type. The data for the first pixel at location (x, y) will be read into the array index specified by the offset parameter. Pixel data for a row will be stored in adjacent locations within the array packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be stored offset from each other by the number of int array elements defined by scanlineStride.

Parameters
x:int

the X coordinate of the rectangular region to read

y:int

the Y coordinate of the rectangular region to read

w:int

the width of the rectangular region to read

h:int

the height of the rectangular region to read

pixelformat:WritablePixelFormat<IntBuffer>

the PixelFormat<IntBuffer> object defining the int format to store the pixels into buffer

buffer:int[]

a int array to store the returned pixel data

offset:int

the offset into buffer to store the first pixel data

scanlineStride:int

the distance between the pixel data for the start of one row of data in the buffer to the start of the next row of data