From 4633376b28293ed74d88cf292c2539824c3bd795 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 22 Mar 2022 17:14:49 -0700 Subject: [PATCH] test: fix crash on image.crop (#33148) * test: fix crash on image.crop * Trigger CI --- spec-main/screen-helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec-main/screen-helpers.ts b/spec-main/screen-helpers.ts index 26fbcb8ea2b0..ea9d69e0f17d 100644 --- a/spec-main/screen-helpers.ts +++ b/spec-main/screen-helpers.ts @@ -41,7 +41,8 @@ const formatHexByte = (val: number): string => { * Get the hex color at the given pixel coordinate in an image. */ export const getPixelColor = (image: Electron.NativeImage, point: Electron.Point): string => { - const pixel = image.crop({ ...point, width: 1, height: 1 }); + // image.crop crashes if point is fractional, so round to prevent that crash + const pixel = image.crop({ x: Math.round(point.x), y: Math.round(point.y), width: 1, height: 1 }); // TODO(samuelmaddock): NativeImage.toBitmap() should return the raw pixel // color, but it sometimes differs. Why is that? const [b, g, r] = pixel.toBitmap();