diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0b01ad1..64d18a1cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added +- [#1913] Retaining shape exact position(bounds) in SVG export (Can be turned on in advanced settings) + ### Fixed - [#1888] AS3 - missing casts in declarations - [#1894] Switch inside loop diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 0a83d945f..6f1c4c570 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -879,6 +879,10 @@ public final class Configuration { @ConfigurationCategory("ui") public static ConfigurationItem showImportSoundInfo = null; + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("export") + public static ConfigurationItem svgRetainBounds = null; + private enum OSId { WINDOWS, OSX, UNIX } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java index c689e7c03..2cdfaeab6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java @@ -96,8 +96,13 @@ public class SVGExporter { Element svgRoot = _svg.getDocumentElement(); svgRoot.setAttribute("xmlns:xlink", xlinkNamespace); if (bounds != null) { - svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px"); - svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px"); + if (Configuration.svgRetainBounds.get()) { + svgRoot.setAttribute("width", (bounds.xMax / SWF.unitDivisor) + "px"); + svgRoot.setAttribute("height", (bounds.yMax / SWF.unitDivisor) + "px"); + } else { + svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px"); + svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px"); + } createDefGroup(bounds, null, zoom); } } catch (ParserConfigurationException ex) { @@ -131,7 +136,12 @@ public class SVGExporter { public final void createDefGroup(ExportRectangle bounds, String id, double zoom) { Element g = _svg.createElement("g"); if (bounds != null) { - Matrix mat = Matrix.getTranslateInstance(-bounds.xMin, -bounds.yMin); + Matrix mat; + if (Configuration.svgRetainBounds.get()) { + mat = new Matrix(); + } else { + mat = Matrix.getTranslateInstance(-bounds.xMin, -bounds.yMin); + } mat.scale(zoom); g.setAttribute("transform", mat.getSvgTransformationString(SWF.unitDivisor, 1)); } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 39234ef58..9f0bc54ee 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -665,3 +665,6 @@ config.description.showImportMovieInfo = Displays some info about how importing config.name.showImportSoundInfo = Show information before importing sounds config.description.showImportSoundInfo = Displays some info about how importing sounds works after clicking Import sounds in the menu. + +config.name.svgRetainBounds = Retain shape bounds during SVG export +config.description.svgRetainBounds = During SVG export, the x, y position of the shape is exported exactly as in SWF (e.g. positive or negative). diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties index 43cef3066..8e88a7d0e 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties @@ -655,3 +655,6 @@ config.description.showImportMovieInfo = Zobraz\u00ed n\u011bjak\u00e9 informace config.name.showImportSoundInfo = Zobrazit informaci p\u0159ed importem zvuk\u016f config.description.showImportSoundInfo = Zobraz\u00ed n\u011bjak\u00e9 informace o tom jak import zvuk\u016f funguje po kliku na import zvuk\u016f v menu. + +config.name.svgRetainBounds = Zachovat hranice tvaru b\u011bhem exportu SVG +config.description.svgRetainBounds = B\u011bhem exportu SVG bude pozice tvaru x a y exportov\u00e1na p\u0159esn\u011b jako v SWF (tj. pozitivn\u00ed \u010di negativn\u00ed).