From 1e50a211b210dd1c968966ae42ecbcb72e59eb35 Mon Sep 17 00:00:00 2001 From: takahirom Date: Fri, 3 Jan 2025 16:59:55 +0900 Subject: [PATCH 1/2] Show diff when the image size is changed --- .../com/github/takahirom/roborazzi/AwtRoboCanvas.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt b/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt index bd8cd765..27c3c3af 100644 --- a/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt +++ b/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt @@ -513,11 +513,15 @@ class AwtRoboCanvas(width: Int, height: Int, filled: Boolean, bufferedImageType: originalImage: BufferedImage, comparedImage: BufferedImage ): BufferedImage { - val width = minOf(originalImage.width, comparedImage.width) - val height = minOf(originalImage.height, comparedImage.height) + val width = maxOf(originalImage.width, comparedImage.width) + val height = maxOf(originalImage.height, comparedImage.height) val diffImage = BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB) for (x in 0 until width) { for (y in 0 until height) { + if (x >= originalImage.width || y >= originalImage.height) { + diffImage.setRGB(x, y, -0x10000) + continue + } val rgbOrig = originalImage.getRGB(x, y) val rgbComp = comparedImage.getRGB(x, y) if (rgbOrig != rgbComp) { From bbd5b08a1e15666f4a6f80a6a90437178489d4f3 Mon Sep 17 00:00:00 2001 From: takahirom Date: Fri, 3 Jan 2025 17:23:53 +0900 Subject: [PATCH 2/2] Fix compare crash bug --- .../kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt b/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt index 27c3c3af..7d4b846f 100644 --- a/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt +++ b/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt @@ -518,7 +518,8 @@ class AwtRoboCanvas(width: Int, height: Int, filled: Boolean, bufferedImageType: val diffImage = BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB) for (x in 0 until width) { for (y in 0 until height) { - if (x >= originalImage.width || y >= originalImage.height) { + if (x >= originalImage.width || y >= originalImage.height + || x >= comparedImage.width || y >= comparedImage.height) { diffImage.setRGB(x, y, -0x10000) continue }