diff --git a/CHANGELOG.md b/CHANGELOG.md index 3acf62f0f..1adc56ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - Correct debug info label position/content on the top of flash viewer to avoid unwanted initial scroll - [#1829] Adding extra pixel to the width and height when rendering items (for example to AVI) - [#1828] Zero scale layer matrices support +- [#1828] Incorrect stroke scaling (normal/none/vertical/horizontal) ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java index c5eaf66c3..b75eef8e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java @@ -123,4 +123,20 @@ public class ExportRectangle { public ExportRectangle toPx() { return new ExportRectangle(Math.round(xMin / 20), Math.round(yMin / 20), Math.round(xMax / 20), Math.round(yMax / 20)); } + + public Point getUpperLeftPoint() { + return new Point(xMin, yMin); + } + + public Point getUpperRightPoint() { + return new Point(xMax, yMin); + } + + public Point getLowerLeftPoint() { + return new Point(xMin, yMax); + } + + public Point getLowerRightPoint() { + return new Point(xMax, yMax); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java index d8f3af00e..fc0713b06 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.commonshape; /** @@ -45,4 +46,15 @@ public class Point { } return false; } + + public double distanceTo(Point p) { + double dx = x - p.x; + double dy = y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + + @Override + public String toString() { + return "[" + x + "," + y + "]"; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index 30dc12e95..be5faedf6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java @@ -45,6 +45,7 @@ import java.awt.TexturePaint; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import java.awt.geom.NoninvertibleTransformException; +import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -92,6 +93,12 @@ public class BitmapExporter extends ShapeExporterBase { private Matrix strokeTransformation; + private double thicknessScale; + private double thicknessScaleX; + private double thicknessScaleY; + + private double realZoom; + private static boolean linearGradientColorWarnignShown = false; private boolean scaleStrokes; @@ -162,12 +169,8 @@ public class BitmapExporter extends ShapeExporterBase { this.image = image; this.scaleStrokes = scaleStrokes; ExportRectangle bounds = new ExportRectangle(shape.getBounds()); - ExportRectangle transformedBounds = strokeTransformation.transform(bounds); - - this.strokeTransformation = Matrix.getScaleInstance( - Double.compare(bounds.getWidth(), 0.0d) == 0 /*horizontal line or single point */ ? 1 : transformedBounds.getWidth() / bounds.getWidth(), - Double.compare(bounds.getHeight(), 0.0d) == 0 /*vertical line or single point */ ? 1 : transformedBounds.getHeight() / bounds.getHeight() - ); + this.strokeTransformation = strokeTransformation; + calculateThicknessScale(bounds, transformation); graphics = (Graphics2D) image.getGraphics(); AffineTransform at = transformation.toTransform(); @@ -177,6 +180,19 @@ public class BitmapExporter extends ShapeExporterBase { super.export(); } + private void calculateThicknessScale(ExportRectangle bounds, Matrix transformation) { + com.jpexs.decompiler.flash.exporters.commonshape.Point p00 = strokeTransformation.transform(0, 0); + com.jpexs.decompiler.flash.exporters.commonshape.Point p11 = strokeTransformation.transform(1, 1); + thicknessScale = p00.distanceTo(p11) / Math.sqrt(2); + thicknessScaleX = Math.abs(p11.x - p00.x); + thicknessScaleY = Math.abs(p11.y - p00.y); + + Matrix transPre = transformation.preConcatenate(Matrix.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); + p00 = transPre.transform(0, 0); + p11 = transPre.transform(1, 1); + realZoom = p00.distanceTo(p11); + } + public SerializableImage getImage() { return image; } @@ -398,21 +414,22 @@ public class BitmapExporter extends ShapeExporterBase { if (scaleStrokes) { switch (scaleMode) { case "VERTICAL": - thickness *= strokeTransformation.scaleY; + thickness *= thicknessScaleY; break; case "HORIZONTAL": - thickness *= strokeTransformation.scaleX; + thickness *= thicknessScaleX; break; case "NORMAL": - thickness *= Math.max(strokeTransformation.scaleX, strokeTransformation.scaleY); + thickness *= thicknessScale; break; case "NONE": break; } } - if (thickness < 0) { - thickness = -thickness; + //always display minimum strokem of 1 pixel, no matter how zoomed it is + if (thickness * realZoom < 1) { + thickness = 1 / realZoom; } if (joinStyle == BasicStroke.JOIN_MITER) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java index 22d4b27eb..959051ba6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java @@ -78,6 +78,9 @@ public abstract class CharacterTag extends Tag implements CharacterIdTag { } public DefineScalingGridTag getScalingGridTag() { + if (swf == null) { //??? + return null; + } return (DefineScalingGridTag) swf.getCharacterIdTag(getCharacterId(), DefineScalingGridTag.ID); } } 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 0de3d1c9b..538861eb5 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 @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types.filters; import com.jpexs.decompiler.flash.types.RGBA; diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java index 1ab8d13fd..7b6456633 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.helpers; import com.jpexs.decompiler.flash.helpers.ImageHelper; diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics.swd b/libsrc/ffdec_lib/testdata/graphics/graphics.swd index 51bed3389..cd1502ed6 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics.swd and b/libsrc/ffdec_lib/testdata/graphics/graphics.swd differ diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics.swf b/libsrc/ffdec_lib/testdata/graphics/graphics.swf index 84fdc6de2..7a3847f16 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics.swf and b/libsrc/ffdec_lib/testdata/graphics/graphics.swf differ diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml index cde07d9fa..a0d00fad4 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml @@ -1,7 +1,7 @@ - + - + @@ -39,23 +39,29 @@ - + - + + + + + + + - + - + - + @@ -68,34 +74,7 @@ }]]> - - - - - - - - - - - - - - - - - - - - - - - - + @@ -196,7 +175,7 @@ - + @@ -276,10 +255,10 @@ + - @@ -808,10 +787,10 @@ !3980 1990|2980 1990!2980 1990|2980 990!2980 990|3980 990!3980 990|3980 1990"/> - + @@ -1410,18 +1389,18 @@ - + - - + + @@ -1443,12 +1422,12 @@ - + - + @@ -1456,7 +1435,7 @@ - + @@ -1469,7 +1448,7 @@ - + @@ -2224,6 +2203,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + scale:vertical + + + + + + + + + + + + + scale:horizontal + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3618,6 +3719,40 @@ + + + + + + + + + 064 Rotated stroke normal scaling + + + + + + + + + + + + + + + + + 065 Rotated vertical/horiz. scaling + + + + + + + + @@ -3625,6 +3760,17 @@ + + + + + + + + + + + @@ -3634,16 +3780,5 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml index 31711240e..a0a61f94e 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml @@ -28,92 +28,91 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + + + + + - - + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml index e775eccfa..21fc928b6 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml @@ -25,9 +25,9 @@ - - + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml index 9f75c9519..a1c282459 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml @@ -28,73 +28,75 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml index e384bea8c..17cdfa5a8 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml @@ -5,8 +5,8 @@ xmlns:xmp="http://ns.adobe.com/xap/1.0/"> Adobe Flash Professional CS6 - build 481 2021-03-14T08:29:20+01:00 - 2021-11-17T11:15:56-08:00 - 2021-11-17T11:15:56-08:00 + 2022-10-23T21:46:13-07:00 + 2022-10-23T21:46:13-07:00 @@ -15,7 +15,7 @@ - xmp.iid:89B07B0DDA47EC11A869CDC6AA3E2CFC + xmp.iid:31A9D48A0F53ED11A79581A4DE002270 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 @@ -122,6 +122,12 @@ 2021-03-14T08:29:20+01:00 Adobe Flash Professional CS6 - build 481 + + created + xmp.iid:31A9D48A0F53ED11A79581A4DE002270 + 2021-03-14T08:29:20+01:00 + Adobe Flash Professional CS6 - build 481 + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache index ebf0d6d13..0ccc70031 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache and b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache differ