From 4777c2a42b3fc0c2850526d239f12179e66c8407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 21 Dec 2025 23:24:36 +0100 Subject: [PATCH] Fixed: #2572 SVG import - incorrect stroke width when transform contains rotation/shear --- CHANGELOG.md | 2 ++ .../decompiler/flash/exporters/commonshape/Matrix.java | 8 ++++---- .../flash/exporters/shape/SVGShapeExporter.java | 4 +--- .../jpexs/decompiler/flash/importers/svg/SvgImporter.java | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ecb78b4..ec9a50a70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - [#2585] AS1/2 direct editation - continue and break in for..in loop - [#2589] SVG export - subsprite animation, sprite offsets - [#1893] Video - incorrect frame size +- [#2572] SVG import - incorrect stroke width when transform contains rotation/shear ### Changed - [#2575] dumpSWF CLI command only allows single SWF dump (no imports, etc.) @@ -4076,6 +4077,7 @@ Major version of SWF to XML export changed to 2. [#2585]: https://www.free-decompiler.com/flash/issues/2585 [#2589]: https://www.free-decompiler.com/flash/issues/2589 [#1893]: https://www.free-decompiler.com/flash/issues/1893 +[#2572]: https://www.free-decompiler.com/flash/issues/2572 [#2556]: https://www.free-decompiler.com/flash/issues/2556 [#2536]: https://www.free-decompiler.com/flash/issues/2536 [#2537]: https://www.free-decompiler.com/flash/issues/2537 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java index fae9c0959..12e951ea2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java @@ -28,13 +28,13 @@ import java.awt.geom.Rectangle2D; */ public final class Matrix implements Cloneable { - public double scaleX = 1; + public double scaleX = 1; //a - public double scaleY = 1; + public double scaleY = 1; //d - public double rotateSkew0; + public double rotateSkew0; //b - public double rotateSkew1; + public double rotateSkew1; //c public double translateX; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java index 85bb2b948..d29343342 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java @@ -107,9 +107,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { this.exporter = exporter; this.displayZoom = displayZoom; - 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); + thicknessScale = Math.sqrt(Math.abs(strokeTransformation.scaleX * strokeTransformation.scaleY - strokeTransformation.rotateSkew0 * strokeTransformation.rotateSkew1)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java index 6a88a0acf..37b44b351 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java @@ -2028,7 +2028,8 @@ public class SvgImporter { ILINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2(); lineStyle.setColor(getRGB(shapeNum, lineColor)); - double scale = Math.max(transform.scaleX, transform.scaleY); + double scale = Math.sqrt(Math.abs(transform.scaleX * transform.scaleY - transform.rotateSkew0 * transform.rotateSkew1)); + lineStyle.setWidth((int) Math.round(style.getStrokeWidth() * scale * SWF.unitDivisor)); SvgLineCap lineCap = style.getStrokeLineCap(); SvgLineJoin lineJoin = style.getStrokeLineJoin();