APIdia Launch Partner
Top Description Methods
javafx.scene.image

public Interface PixelWriter

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

This interface defines methods for writing the pixel data of a WritableImage or other surface containing writable pixels.
Since
JavaFX 2.2

Method Summary

Modifier and TypeMethod and Description
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 from which it can easily convert pixels for purposes of writing them.

public void
setArgb(int
the X coordinate of the pixel color to write
x
,
int
the Y coordinate of the pixel color to write
y
,
int
the color information to write, specified in the format described by the INT_ARGB PixelFormat type.
argb
)

Stores pixel data for a color into the specified coordinates of the surface.

public void
setColor(int
the X coordinate of the pixel color to write
x
,
int
the Y coordinate of the pixel color to write
y
,
Color
the Color to write or null
c
)

Stores pixel data for a Color into the specified coordinates of the surface.

public <
the type of the buffer
T extends Buffer
>
void
setPixels(int
the X coordinate of the rectangular region to write
x
,
int
the Y coordinate of the rectangular region to write
y
,
int
the width of the rectangular region to write
w
,
int
the height of the rectangular region to write
h
,
PixelFormat<T>
the PixelFormat object defining the format to read the pixels from the 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
)

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

public void
setPixels(int
the X coordinate of the rectangular region to write
x
,
int
the Y coordinate of the rectangular region to write
y
,
int
the width of the rectangular region to write
w
,
int
the height of the rectangular region to write
h
,
PixelFormat<ByteBuffer>
the PixelFormat<ByteBuffer> object defining the byte format to read the pixels from buffer
pixelformat
,
byte[]
a byte array containing the pixel data to store
buffer
,
int
the offset into buffer to read 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
)

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

public void
setPixels(int
the X coordinate of the rectangular region to write
x
,
int
the Y coordinate of the rectangular region to write
y
,
int
the width of the rectangular region to write
w
,
int
the height of the rectangular region to write
h
,
PixelFormat<IntBuffer>
the PixelFormat<IntBuffer> object defining the int format to read the pixels from buffer
pixelformat
,
int[]
an int array to containing the pixel data to store
buffer
,
int
the offset into buffer to read 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
)

Stores pixel data from an int array into a rectangular region of the surface.

public void
setPixels(int
the X coordinate of the rectangular region to write
dstx
,
int
the Y coordinate of the rectangular region to write
dsty
,
int
the width of the rectangular region to write
w
,
int
the height of the rectangular region to write
h
,
PixelReader
the PixelReader used to get the pixel data to write
reader
,
int
the X coordinate of the data to read from reader
srcx
,
int
the Y coordinate of the data to read from reader
srcy
)

Stores pixel data retrieved from a PixelReader instance into a rectangular region of the surface.

Method Detail

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 from which it can easily convert pixels for purposes of writing them.

Returns:PixelFormat<T extends Buffer>

the PixelFormat that best describes the underlying pixels

setArgbback to summary
public void setArgb(int x, int y, int argb)

Stores pixel data for a color into the specified coordinates of the surface. The 32-bit integer argb parameter should 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 write

y:int

the Y coordinate of the pixel color to write

argb:int

the color information to write, specified in the format described by the INT_ARGB PixelFormat type.

setColorback to summary
public void setColor(int x, int y, Color c)

Stores pixel data for a Color into the specified coordinates of the surface.

Parameters
x:int

the X coordinate of the pixel color to write

y:int

the Y coordinate of the pixel color to write

c:Color

the Color to write or null

Exceptions
NullPointerException:
if color is null
setPixelsback to summary
public <T extends Buffer> void setPixels(int x, int y, int w, int h, PixelFormat<T> pixelformat, T buffer, int scanlineStride)

Stores pixel data from a buffer into a rectangular region of the surface. The format of the pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data into the surface. The buffer is assumed to be positioned to the location where the first pixel data to be stored in the surface pixel at location (x, y) is located. Pixel data for a row will be read from adjacent locations within the buffer packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be read 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 write

y:int

the Y coordinate of the rectangular region to write

w:int

the width of the rectangular region to write

h:int

the height of the rectangular region to write

pixelformat:PixelFormat<T>

the PixelFormat object defining the format to read the pixels from the 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.

Exceptions
NullPointerException:
if pixelformat or buffer is null
setPixelsback to summary
public void setPixels(int x, int y, int w, int h, PixelFormat<ByteBuffer> pixelformat, byte[] buffer, int offset, int scanlineStride)

Stores pixel data from a byte array into a rectangular region of the surface. The format of the pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data into the surface. The pixelformat must be a compatible PixelFormat<ByteBuffer> type. The data for the first pixel at location (x, y) will be read from the array index specified by the offset parameter. Pixel data for a row will be read from adjacent locations within the array packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be read 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 write

y:int

the Y coordinate of the rectangular region to write

w:int

the width of the rectangular region to write

h:int

the height of the rectangular region to write

pixelformat:PixelFormat<ByteBuffer>

the PixelFormat<ByteBuffer> object defining the byte format to read the pixels from buffer

buffer:byte[]

a byte array containing the pixel data to store

offset:int

the offset into buffer to read 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

Exceptions
NullPointerException:
if pixelformat or buffer is null
setPixelsback to summary
public void setPixels(int x, int y, int w, int h, PixelFormat<IntBuffer> pixelformat, int[] buffer, int offset, int scanlineStride)

Stores pixel data from an int array into a rectangular region of the surface. The format of the pixels in the buffer is defined by the PixelFormat object and pixel format conversions will be performed as needed to store the data into the surface. The pixelformat must be a compatible PixelFormat<IntBuffer> type. The data for the first pixel at location (x, y) will be read from the array index specified by the offset parameter. Pixel data for a row will be read from adjacent locations within the array packed as tightly as possible for increasing X coordinates. Pixel data for adjacent rows will be read 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 write

y:int

the Y coordinate of the rectangular region to write

w:int

the width of the rectangular region to write

h:int

the height of the rectangular region to write

pixelformat:PixelFormat<IntBuffer>

the PixelFormat<IntBuffer> object defining the int format to read the pixels from buffer

buffer:int[]

an int array to containing the pixel data to store

offset:int

the offset into buffer to read 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

Exceptions
NullPointerException:
if pixelformat or buffer is null
setPixelsback to summary
public void setPixels(int dstx, int dsty, int w, int h, PixelReader reader, int srcx, int srcy)

Stores pixel data retrieved from a PixelReader instance into a rectangular region of the surface. The data for the pixel on the surface at (dstx, dsty) will be retrieved from the reader from its location (srcx, srcy). This method performs an operation which is semantically equivalent to (though likely much faster than) this pseudo-code:

    for (int y = 0; y < h, y++) {
        for (int x = 0; x < w; x++) {
            setArgb(dstx + x, dsty + y,
                    reader.getArgb(srcx + x, srcy + y));
        }
    }
Parameters
dstx:int

the X coordinate of the rectangular region to write

dsty:int

the Y coordinate of the rectangular region to write

w:int

the width of the rectangular region to write

h:int

the height of the rectangular region to write

reader:PixelReader

the PixelReader used to get the pixel data to write

srcx:int

the X coordinate of the data to read from reader

srcy:int

the Y coordinate of the data to read from reader

Exceptions
NullPointerException:
if reader is null