Class ImageDataPixelReader
java.lang.Object
dev.webfx.kit.mapper.peers.javafxgraphics.gwtj2cl.html.ImageDataPixelReader
- All Implemented Interfaces:
PixelReader
- Author:
- Bruno Salmon
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetArgb(int x, int y) Reads a 32-bit integer representation of the color of a pixel from the specified coordinates in the surface.getColor(int x, int y) Reads the color of a pixel from the specified coordinates in the surface and returns the value as aColorobject.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.
-
Constructor Details
-
ImageDataPixelReader
public ImageDataPixelReader(elemental2.dom.ImageData imageData)
-
-
Method Details
-
getPixelFormat
Description copied from interface:PixelReaderThis 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.- Specified by:
getPixelFormatin interfacePixelReader- Returns:
- the
PixelFormatthat best describes the underlying pixels
-
getArgb
public int getArgb(int x, int y) Description copied from interface:PixelReaderReads 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.- Specified by:
getArgbin interfacePixelReader- Parameters:
x- the X coordinate of the pixel color to ready- the Y coordinate of the pixel color to read- Returns:
- a 32-bit representation of the color in the format
described by the
INT_ARGBPixelFormat type.
-
getColor
Description copied from interface:PixelReaderReads the color of a pixel from the specified coordinates in the surface and returns the value as aColorobject.- Specified by:
getColorin interfacePixelReader- Parameters:
x- the X coordinate of the pixel color to ready- the Y coordinate of the pixel color to read- Returns:
- the Color object representing the color of the indicated pixel
-
getPixels
public <T extends Buffer> void getPixels(int x, int y, int w, int h, WritablePixelFormat<T> pixelformat, T buffer, int scanlineStride) Description copied from interface:PixelReaderReads 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.- Specified by:
getPixelsin interfacePixelReader- Type Parameters:
T- the type of the buffer- Parameters:
x- the X coordinate of the rectangular region to ready- the Y coordinate of the rectangular region to readw- the width of the rectangular region to readh- the height of the rectangular region to readpixelformat- thePixelFormatobject defining the format to store the pixels into bufferbuffer- a buffer of a type appropriate for the indicatedPixelFormatobjectscanlineStride- 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.
-
getPixels
public void getPixels(int x, int y, int w, int h, WritablePixelFormat<ByteBuffer> pixelformat, byte[] buffer, int offset, int scanlineStride) Description copied from interface:PixelReaderReads 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.- Specified by:
getPixelsin interfacePixelReader- Parameters:
x- the X coordinate of the rectangular region to ready- the Y coordinate of the rectangular region to readw- the width of the rectangular region to readh- the height of the rectangular region to readpixelformat- thePixelFormat<ByteBuffer>object defining the byte format to store the pixels into bufferbuffer- a byte array to store the returned pixel dataoffset- the offset intobufferto store the first pixel datascanlineStride- 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
-
getPixels
public void getPixels(int x, int y, int w, int h, WritablePixelFormat<IntBuffer> pixelformat, int[] buffer, int offset, int scanlineStride) Description copied from interface:PixelReaderReads 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.- Specified by:
getPixelsin interfacePixelReader- Parameters:
x- the X coordinate of the rectangular region to ready- the Y coordinate of the rectangular region to readw- the width of the rectangular region to readh- the height of the rectangular region to readpixelformat- thePixelFormat<IntBuffer>object defining the int format to store the pixels into bufferbuffer- a int array to store the returned pixel dataoffset- the offset intobufferto store the first pixel datascanlineStride- 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
-