Interface PixelWriter
public interface PixelWriter
WritableImage or other surface containing writable pixels.Since:
JavaFX 2.2
-
Method Summary
All MethodsInstance MethodsAbstract Methods Modifier and Type Method and Description PixelFormatgetPixelFormat()This method returns thePixelFormatin which the surface stores its pixels, or a roughly equivalent pixel format from which it can easily convert pixels for purposes of writing them.voidsetArgb(int x, int y, int argb)Stores pixel data for a color into the specified coordinates of the surface.voidsetColor(int x, int y, Color c)Stores pixel data for aColorinto the specified coordinates of the surface.voidsetPixels(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.voidsetPixels(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.<T extends Buffer>
voidsetPixels(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.voidsetPixels(int dstx, int dsty, int w, int h, PixelReader reader, int srcx, int srcy)Stores pixel data retrieved from aPixelReaderinstance into a rectangular region of the surface.
-
Method Detail
-
getPixelFormat
PixelFormat getPixelFormat()
This method returns thePixelFormatin 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:
the
PixelFormatthat best describes the underlying pixels
-
setArgb
void setArgb(int x, int y, int argb)Stores pixel data for a color into the specified coordinates of the surface. The 32-bit integerargbparameter 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- the X coordinate of the pixel color to write
-
setColor
void setColor(int x, int y, Color c)Stores pixel data for aColorinto the specified coordinates of the surface.Parameters:
x- the X coordinate of the pixel color to writeThrows:
NullPointerException- ifcolorisnull
-
setPixels
<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 thePixelFormatobject 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to writeThrows:
NullPointerException- if @{code pixelformat} orbufferisnull
-
setPixels
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 thePixelFormatobject and pixel format conversions will be performed as needed to store the data into the surface. Thepixelformatmust be a compatiblePixelFormat<ByteBuffer>type. The data for the first pixel at location(x, y)will be read from the array index specified by theoffsetparameter. 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to writeThrows:
NullPointerException- if @{code pixelformat} orbufferisnull
-
setPixels
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 thePixelFormatobject and pixel format conversions will be performed as needed to store the data into the surface. Thepixelformatmust be a compatiblePixelFormat<IntBuffer>type. The data for the first pixel at location(x, y)will be read from the array index specified by theoffsetparameter. 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to writeThrows:
NullPointerException- if @{code pixelformat} orbufferisnull
-
setPixels
void setPixels(int dstx, int dsty, int w, int h, PixelReader reader, int srcx, int srcy)Stores pixel data retrieved from aPixelReaderinstance into a rectangular region of the surface. The data for the pixel on the surface at(dstx, dsty)will be retrieved from thereaderfrom 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- the X coordinate of the rectangular region to writeThrows:
NullPointerException- if @{code reader} isnull
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.