From c88491b44f41cf4233b8f439d87ee13380815e13 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Mon, 27 Apr 2026 11:37:45 +0100 Subject: [PATCH] fix: facepaint texture color inaccuracies (#47) --- shared/src/switch-tomodachi-life-mii.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/src/switch-tomodachi-life-mii.ts b/shared/src/switch-tomodachi-life-mii.ts index e45536f..e270de7 100644 --- a/shared/src/switch-tomodachi-life-mii.ts +++ b/shared/src/switch-tomodachi-life-mii.ts @@ -91,6 +91,15 @@ export class SwitchTomodachiLifeMii { const decompressed = Buffer.from(fzstd.decompress(canvasData)); const deswizzled = new BytesDeswizzle(decompressed, [256, 256], [1, 1], 4, 4).deswizzle(); + // Issue (#47) + const gamma = 0.4545; + + for (let i = 0; i < deswizzled.length; i += 4) { + deswizzled[i] = Math.min(255, Math.round(255 * Math.pow(deswizzled[i] / 255, gamma))); + deswizzled[i + 1] = Math.min(255, Math.round(255 * Math.pow(deswizzled[i + 1] / 255, gamma))); + deswizzled[i + 2] = Math.min(255, Math.round(255 * Math.pow(deswizzled[i + 2] / 255, gamma))); + } + return await sharp(deswizzled, { raw: { width: 256, height: 256, channels: 4 }, })