SnapshotImage
final class SnapshotImage
Package: dev.joid.test.snapshot · Module: tool-testkit · Source: SnapshotImage.java
The pixels of a snapshot, as opaque ARGB int values row after row from the top-left corner.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
SnapshotImage | from(ByteBuffer buffer, int width, int height, boolean bottomUp, PixelLayout layout) factory | Reads the pixels of a capture in that layout, bottom row first when the boolean is true, and makes them opaque. |
SnapshotImage | read(File file) factory | Reads a PNG file; throws an UncheckedIOException when it cannot be read or decoded. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | write(File file) | Writes the image as a PNG file, creating its folders; throws an UncheckedIOException when it cannot be written. |
boolean | isSame(SnapshotImage other) | If true, both images have the same size and the same pixels. |
void | fill(int x, int y, int width, int height, int color) | Fills that rectangle, clipped to the image, with that ARGB color. |
SnapshotDifference | compare(SnapshotImage reference, int tolerance) | Returns how much the image differs from the reference: the pixels whose largest channel difference is above the tolerance, every pixel when the sizes differ. |
int | getWidth() | Returns the width, in pixels. |
int | getHeight() | Returns the height, in pixels. |
int[] | getPixels() | Returns the pixels, ARGB, row after row from the top-left corner. |
Creation details
Section titled “Creation details”SnapshotImage from(ByteBuffer buffer, int width, int height, boolean bottomUp, PixelLayout layout) factory
Reads the pixels of a capture in that layout, bottom row first when the boolean is true, and makes them opaque.
SnapshotImage read(File file) factory
Throws:
IOException: The image … cannot be decoded, check that it is a valid PNGUncheckedIOException: …
Reads a PNG file; throws an UncheckedIOException when it cannot be read or decoded.
Method details
Section titled “Method details”void write(File file)
Throws:
UncheckedIOException: …
Writes the image as a PNG file, creating its folders; throws an UncheckedIOException when it cannot be written.
isSame
Section titled “isSame”boolean isSame(SnapshotImage other)
If true, both images have the same size and the same pixels.
void fill(int x, int y, int width, int height, int color)
Fills that rectangle, clipped to the image, with that ARGB color.
compare
Section titled “compare”SnapshotDifference compare(SnapshotImage reference, int tolerance)
Returns how much the image differs from the reference: the pixels whose largest channel difference is above the tolerance, every pixel when the sizes differ.
getWidth
Section titled “getWidth”int getWidth()
Returns the width, in pixels.
getHeight
Section titled “getHeight”int getHeight()
Returns the height, in pixels.
getPixels
Section titled “getPixels”int[] getPixels()
Returns the pixels, ARGB, row after row from the top-left corner.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
