From 918389cd1a2385f2498a78ac82340c31b0af72f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 24 Sep 2024 20:59:40 +0200 Subject: [PATCH] Fixed: #2272 Filters strength attribute caps at 100% --- CHANGELOG.md | 2 ++ .../decompiler/flash/types/filters/Filtering.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c02b05393..5d65bac2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - [#2319] AS3 Compound assignments problems in some cases - [#2319] AS3 direct editation - class gets removed after pressing cancel - [#2320] AS3 direct editation - modified flag of scripts vanishes after editing other script with and having error +- [#2272] Filters strength attribute caps at 100% ## [21.1.0] - 2024-09-23 ### Added @@ -3580,6 +3581,7 @@ Major version of SWF to XML export changed to 2. [#2321]: https://www.free-decompiler.com/flash/issues/2321 [#2319]: https://www.free-decompiler.com/flash/issues/2319 [#2320]: https://www.free-decompiler.com/flash/issues/2320 +[#2272]: https://www.free-decompiler.com/flash/issues/2272 [#943]: https://www.free-decompiler.com/flash/issues/943 [#1812]: https://www.free-decompiler.com/flash/issues/1812 [#2287]: https://www.free-decompiler.com/flash/issues/2287 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/Filtering.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/Filtering.java index 5282ae7e1..ee8e8f189 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/Filtering.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/Filtering.java @@ -367,8 +367,7 @@ public class Filtering { if (inner) { alpha = 255 - alpha; } - Color shadowColor; - shadowColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), cut(color.getAlpha() * alpha / 255 * strength)); + Color shadowColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), cut(color.getAlpha() * alpha / 255f)); shadow[i] = shadowColor.getRGB(); } @@ -382,6 +381,14 @@ public class Filtering { blur(shadow, width, height, blurX, blurY, iterations, null); } + if (strength != 1f) { + for (int i = 0; i < shadow.length; i++) { + int alpha = (shadow[i] >> 24) & 0xff; + alpha = cut(alpha * strength); + shadow[i] = (shadow[i] & 0xffffff) | (alpha << 24); + } + } + if (knockout || inner) { for (int i = 0; i < shadow.length; i++) { int mask = (srcPixels[i] >> 24) & 0xff;