Skip to content

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.

ReturnsSignatureSummary
SnapshotImagefrom(ByteBuffer buffer, int width, int height, boolean bottomUp, PixelLayout layout) factoryReads the pixels of a capture in that layout, bottom row first when the boolean is true, and makes them opaque.
SnapshotImageread(File file) factoryReads a PNG file; throws an UncheckedIOException when it cannot be read or decoded.

ReturnsSignatureSummary
voidwrite(File file)Writes the image as a PNG file, creating its folders; throws an UncheckedIOException when it cannot be written.
booleanisSame(SnapshotImage other)If true, both images have the same size and the same pixels.
voidfill(int x, int y, int width, int height, int color)Fills that rectangle, clipped to the image, with that ARGB color.
SnapshotDifferencecompare(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.
intgetWidth()Returns the width, in pixels.
intgetHeight()Returns the height, in pixels.
int[]getPixels()Returns the pixels, ARGB, row after row from the top-left corner.

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 PNG
  • UncheckedIOException: …

Reads a PNG file; throws an UncheckedIOException when it cannot be read or decoded.

void write(File file)

Throws:

  • UncheckedIOException: …

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.


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

Report a problem with this page