package p.studio.api.automation; import java.util.Objects; /** Lossless PNG bytes; stride describes the original RGBA8888 buffer, not PNG padding. */ public record CanonicalCapture(String sessionId, String buildId, java.math.BigInteger logicalFrameIndex, java.math.BigInteger frameId, int width, int height, int stridePixels, byte[] png) { public CanonicalCapture(String sessionId, String buildId, long logicalFrameIndex, long frameId, int width, int height, int stridePixels, byte[] png) { this(sessionId, buildId, java.math.BigInteger.valueOf(logicalFrameIndex), java.math.BigInteger.valueOf(frameId), width, height, stridePixels, png); } public CanonicalCapture { Objects.requireNonNull(sessionId); Objects.requireNonNull(buildId); Objects.requireNonNull(png); if (logicalFrameIndex.signum() < 0 || logicalFrameIndex.bitLength() > 64 || frameId.signum() < 0 || frameId.bitLength() > 64) throw new IllegalArgumentException("Frame identity must be uint64"); if (width <= 0 || height <= 0 || stridePixels < width) throw new IllegalArgumentException("invalid frame layout"); png = png.clone(); } @Override public byte[] png() { return png.clone(); } }