Interface PixelReader
public interface PixelReader
Image or other surface containing pixels.Since:
JavaFX 2.2
-
Method Summary
All MethodsInstance MethodsAbstract Methods Modifier and Type Method and Description intgetArgb(int x, int y)Reads a 32-bit integer representation of the color of a pixel from the specified coordinates in the surface.ColorgetColor(int x, int y)Reads the color of a pixel from the specified coordinates in the surface and returns the value as aColorobject.PixelFormatgetPixelFormat()This method returns thePixelFormatin 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.voidgetPixels(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.voidgetPixels(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.<T extends Buffer>
voidgetPixels(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.
-
Method Detail
-
getPixelFormat
PixelFormat getPixelFormat()
This method returns thePixelFormatin 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:
the
PixelFormatthat best describes the underlying pixels
-
getArgb
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- the X coordinate of the pixel color to readReturns:
a 32-bit representation of the color in the format described by the
INT_ARGBPixelFormat type.
-
getColor
Color getColor(int x, int y)Reads the color of a pixel from the specified coordinates in the surface and returns the value as aColorobject.Parameters:
x- the X coordinate of the pixel color to readReturns:
the Color object representing the color of the indicated pixel
-
getPixels
<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 thePixelFormatobject 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to read
-
getPixels
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 thePixelFormatobject and pixel format conversions will be performed as needed to store the data in the indicated format. Thepixelformatmust be a compatiblePixelFormat<ByteBuffer>type. The data for the first pixel at location(x, y)will be read into the array index specified by theoffsetparameter. 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to read
-
getPixels
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 thePixelFormatobject and pixel format conversions will be performed as needed to store the data in the indicated format. Thepixelformatmust be a compatiblePixelFormat<IntBuffer>type. The data for the first pixel at location(x, y)will be read into the array index specified by theoffsetparameter. 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 byscanlineStride.Parameters:
x- the X coordinate of the rectangular region to read
-
© 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.