From b712fd4b440e41acc8d06fb94604d60798302418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 3 Nov 2022 22:16:44 +0100 Subject: [PATCH] Fixed Flash viewer - dropshadow filter hideobject(compositeSource) parameter --- CHANGELOG.md | 1 + .../flash/types/filters/DROPSHADOWFILTER.java | 2 +- .../flash/types/filters/Filtering.java | 30 ++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b296042d..ba8b43d51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Expand correct tree on SWF load - [#1679] FLA export - MorphShapes (shape tween) - [#1860], [#1732], [#1837] FLA export - AS3 - missing framescripts on the timeline +- Flash viewer - dropshadow filter hideobject(compositeSource) parameter ## [16.0.3] - 2022-11-02 ### Fixed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java index 12ade420e..1b33b3002 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java @@ -93,7 +93,7 @@ public class DROPSHADOWFILTER extends FILTER { @Override public SerializableImage apply(SerializableImage src, double zoom) { - return Filtering.dropShadow(src, (int) Math.round(blurX * zoom), (int) Math.round(blurY * zoom), (int) (angle * 180 / Math.PI), distance * zoom, dropShadowColor.toColor(), innerShadow, passes, strength, knockout); + return Filtering.dropShadow(src, (int) Math.round(blurX * zoom), (int) Math.round(blurY * zoom), (int) (angle * 180 / Math.PI), distance * zoom, dropShadowColor.toColor(), innerShadow, passes, strength, knockout, compositeSource); } @Override 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 538861eb5..4235c7c87 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 @@ -286,8 +286,8 @@ public class Filtering { BufferedImage shadowInner = null; BufferedImage hilightInner = null; if (type != OUTER) { - BufferedImage hilightIm = dropShadow(src, 0, 0, angle, distance, Color.red, true, iterations, strength, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src - BufferedImage shadowIm = dropShadow(src, 0, 0, angle + 180, distance, Color.blue, true, iterations, strength, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src); + BufferedImage hilightIm = dropShadow(src, 0, 0, angle, distance, Color.red, true, iterations, strength, true, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src + BufferedImage shadowIm = dropShadow(src, 0, 0, angle + 180, distance, Color.blue, true, iterations, strength, true, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src); BufferedImage h2 = new BufferedImage(width, height, src.getType()); BufferedImage s2 = new BufferedImage(width, height, src.getType()); Graphics2D hc = h2.createGraphics(); @@ -306,8 +306,8 @@ public class Filtering { BufferedImage shadowOuter = null; BufferedImage hilightOuter = null; if (type != INNER) { - BufferedImage hilightIm = dropShadow(src, 0, 0, angle + 180, distance, Color.red, false, iterations, strength, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src - BufferedImage shadowIm = dropShadow(src, 0, 0, angle, distance, Color.blue, false, iterations, strength, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src); + BufferedImage hilightIm = dropShadow(src, 0, 0, angle + 180, distance, Color.red, false, iterations, strength, true, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src + BufferedImage shadowIm = dropShadow(src, 0, 0, angle, distance, Color.blue, false, iterations, strength, true, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src); BufferedImage h2 = new BufferedImage(width, height, src.getType()); BufferedImage s2 = new BufferedImage(width, height, src.getType()); Graphics2D hc = h2.createGraphics(); @@ -382,11 +382,11 @@ public class Filtering { } public static SerializableImage glow(SerializableImage src, int blurX, int blurY, float strength, Color color, boolean inner, boolean knockout, int iterations) { - return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, 45, 0, color, inner, iterations, strength, knockout)); + return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, 45, 0, color, inner, iterations, strength, knockout, true)); } - public static SerializableImage dropShadow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout) { - return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, angle, distance, color, inner, iterations, strength, knockout)); + public static SerializableImage dropShadow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout, boolean compositeSource) { + return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, angle, distance, color, inner, iterations, strength, knockout, compositeSource)); } private static int cut(int val, int min, int max) { @@ -399,7 +399,7 @@ public class Filtering { return val; } - private static BufferedImage dropShadow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout) { + private static BufferedImage dropShadow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout, boolean compositeSource) { int width = src.getWidth(); int height = src.getHeight(); int[] srcPixels = getRGB(src); @@ -424,18 +424,20 @@ public class Filtering { blur(shadow, width, height, blurX, blurY, iterations, null); } - for (int i = 0; i < shadow.length; i++) { - int mask = (srcPixels[i] >> 24) & 0xff; - if (!inner) { - mask = 255 - mask; + if (compositeSource) { + for (int i = 0; i < shadow.length; i++) { + int mask = (srcPixels[i] >> 24) & 0xff; + if (!inner) { + mask = 255 - mask; + } + shadow[i] = shadow[i] & 0xffffff + ((mask * ((shadow[i] >> 24) & 0xff) / 255) << 24); } - shadow[i] = shadow[i] & 0xffffff + ((mask * ((shadow[i] >> 24) & 0xff) / 255) << 24); } BufferedImage retCanvas = new BufferedImage(width, height, src.getType()); setRGB(retCanvas, width, height, shadow); - if (!knockout) { + if (!knockout && compositeSource) { Graphics2D g = retCanvas.createGraphics(); g.setComposite(AlphaComposite.DstOver); g.drawImage(src, 0, 0, null);