From 4e2d8dce36d8edee3a2f4ba105ea91ee88223e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 14 Apr 2024 18:22:56 +0200 Subject: [PATCH] Fixed #2224 Exporting Embed assets - handling DefineBits(+JPEGTables) - convert to DefineBitsJPEG2 --- CHANGELOG.md | 2 ++ .../exporters/script/AS3ScriptExporter.java | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 777e42acd..17eca7d43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ All notable changes to this project will be documented in this file. - [#2202] AS2 detection of uninitialized class fields colliding with setters/getters - [#2202] AS2 return in constructor does not take a value - [#2222] Missing shapes when gradient fillstyle has only two gradrecords with the same ratio +- [#2224] Exporting Embed assets - handling DefineBits(+JPEGTables) - convert to DefineBitsJPEG2 ### Changed - [#2185] MochiCrypt no longer offered for auto decrypt, user needs to choose variant from "Use unpacker" menu @@ -3405,6 +3406,7 @@ Major version of SWF to XML export changed to 2. [#2212]: https://www.free-decompiler.com/flash/issues/2212 [#2202]: https://www.free-decompiler.com/flash/issues/2202 [#2222]: https://www.free-decompiler.com/flash/issues/2222 +[#2224]: https://www.free-decompiler.com/flash/issues/2224 [#2206]: https://www.free-decompiler.com/flash/issues/2206 [#2100]: https://www.free-decompiler.com/flash/issues/2100 [#2123]: https://www.free-decompiler.com/flash/issues/2123 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index 9e2f76ac6..9ca374883 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -64,6 +64,8 @@ import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings; import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsTag; import com.jpexs.decompiler.flash.tags.DefineFont4Tag; import com.jpexs.decompiler.flash.tags.DefineSoundTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; @@ -82,6 +84,7 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; @@ -91,6 +94,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -570,12 +574,25 @@ public class AS3ScriptExporter { st.getNeededCharactersDeep(neededCharacters); neededCharacters.add(st.spriteId); } - for (int n : neededCharacters) { + for (int n : neededCharacters) { CharacterTag ct = (CharacterTag) swf.getCharacter(n); if (ct == null) { continue; } - ct.writeTag(sos2); + if (ct instanceof DefineBitsTag) { + //Convert DefineBits+(global)JPEGTables to standalone DefineBitsJPEG2 so they do not share same JPEGTables anymore + DefineBitsTag db = (DefineBitsTag) ct; + InputStream isd = db.getOriginalImageData(); + if (isd == null) { + continue; + } + DefineBitsJPEG2Tag dbj2 = new DefineBitsJPEG2Tag(swf); + dbj2.characterID = db.characterID; + dbj2.imageData = new ByteArrayRange(Helper.readStream(isd)); + dbj2.writeTag(sos2); + } else { + ct.writeTag(sos2); + } for (String cls : ct.getClassNames()) { symbolClassIds.add(ct.getCharacterId()); symbolClassNames.add(cls);