From 3f147068ea43876d0a94a500b197e07aa077a0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 17 Nov 2021 22:09:30 +0100 Subject: [PATCH] Added #1744 SVG shape import from commandline --- CHANGELOG.md | 2 ++ .../flash/console/CommandLineArgumentParser.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d04a6e15..d19972c56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - GFX: Support for loading external images - Updated Japanese translation - Try loading .gfx files if .swf failed to load for imports and similar +- [#1744] SVG shape import from commandline ### Fixed - [#1687] Slow speed of cyclic tags detection @@ -2202,6 +2203,7 @@ All notable changes to this project will be documented in this file. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1485]: https://www.free-decompiler.com/flash/issues/1485 [#1681]: https://www.free-decompiler.com/flash/issues/1681 +[#1744]: https://www.free-decompiler.com/flash/issues/1744 [#1687]: https://www.free-decompiler.com/flash/issues/1687 [#1748]: https://www.free-decompiler.com/flash/issues/1748 [#1015]: https://www.free-decompiler.com/flash/issues/1015 diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 433cf5a64..60009b02a 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -115,6 +115,7 @@ import com.jpexs.decompiler.flash.importers.SwfXmlImporter; import com.jpexs.decompiler.flash.importers.TextImporter; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException; +import com.jpexs.decompiler.flash.importers.svg.SvgImporter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; @@ -2932,6 +2933,7 @@ public class CommandLineArgumentParser { CharacterTag characterTag = swf.getCharacter(characterId); String repFile = args.pop(); byte[] data = Helper.readFile(repFile); + String ext = Path.getExtension(repFile); if (characterTag instanceof DefineBinaryDataTag) { DefineBinaryDataTag defineBinaryData = (DefineBinaryDataTag) characterTag; new BinaryDataImporter().importData(defineBinaryData, data); @@ -2945,9 +2947,15 @@ public class CommandLineArgumentParser { args.pop(); fill = false; } - int format = parseImageFormat(args); ShapeTag shapeTag = (ShapeTag) characterTag; - new ShapeImporter().importImage(shapeTag, data, format, fill); + + if (".svg".equals(ext)) { + String svgText = Helper.readTextFile(repFile); + new SvgImporter().importSvg(shapeTag, svgText); + } else { + int format = parseImageFormat(args); + new ShapeImporter().importImage(shapeTag, data, format, fill); + } } else if (characterTag instanceof TextTag) { TextTag textTag = (TextTag) characterTag; new TextImporter(new MissingCharacterHandler(), new TextImportErrorHandler() {