From 9a2cd3d85589d0fe0a8d11be4ab52cd68d6bf72a Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Wed, 24 Jul 2024 16:27:06 +0200 Subject: [PATCH] fix: color shift in FeColorMatrix on android (#2365) # Summary While debugging #2364 I've noticed that color shift in `FeColorMatrix` on Android is wrong. On web, elements 5, 10, 15, 20 is a color shift represented by number where 1 mean full color shift, while on Android it's 255 for full color shift. ## Test ```tsx ``` --- android/src/main/java/com/horcrux/svg/FeColorMatrixView.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/horcrux/svg/FeColorMatrixView.java b/android/src/main/java/com/horcrux/svg/FeColorMatrixView.java index 532011a9..877ae263 100644 --- a/android/src/main/java/com/horcrux/svg/FeColorMatrixView.java +++ b/android/src/main/java/com/horcrux/svg/FeColorMatrixView.java @@ -44,7 +44,7 @@ class FeColorMatrixView extends FilterPrimitiveView { float[] rawMatrix = new float[mValues.size()]; for (int i = 0; i < this.mValues.size(); i++) { - rawMatrix[i] = (float) this.mValues.getDouble(i); + rawMatrix[i] = (float) this.mValues.getDouble(i) * (i % 5 == 4 ? 255 : 1); } colorMatrix.set(rawMatrix); @@ -88,8 +88,7 @@ class FeColorMatrixView extends FilterPrimitiveView { case LUMINANCE_TO_ALPHA: colorMatrix.set( new float[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2125f, 0.7154f, 0.0721f, 0, 0, 0, 0, 0, - 0, 1 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2125f, 0.7154f, 0.0721f, 0, 0, }); break; }