Class ScreenshotHelper

java.lang.Object
dev.engine.graphics.ScreenshotHelper

public final class ScreenshotHelper extends Object
Saves RGBA8 framebuffer data as PNG. Backend-agnostic.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    diffPercentage(byte[] a, byte[] b, int threshold)
    Returns the percentage of pixels that differ by more than the given threshold.
    static int
    maxDifference(byte[] a, byte[] b)
    Compares two RGBA8 framebuffers pixel-by-pixel.
    static void
    save(byte[] rgba, int width, int height, String path)
    Saves RGBA8 byte array as a PNG file.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • save

      public static void save(byte[] rgba, int width, int height, String path) throws IOException
      Saves RGBA8 byte array as a PNG file. Alpha is forced to opaque.
      Throws:
      IOException
    • maxDifference

      public static int maxDifference(byte[] a, byte[] b)
      Compares two RGBA8 framebuffers pixel-by-pixel. Returns the maximum per-channel difference across all pixels.
    • diffPercentage

      public static double diffPercentage(byte[] a, byte[] b, int threshold)
      Returns the percentage of pixels that differ by more than the given threshold.