diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index f49d54729..340c6b803 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -91,6 +91,7 @@ import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; import com.jpexs.decompiler.flash.tags.MetadataTag; import com.jpexs.decompiler.flash.tags.ProtectTag; +import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SymbolClassTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -562,6 +563,16 @@ public final class SWF implements SWFContainerItem, Timelined { return null; } + public SetBackgroundColorTag getBackgroundColor() { + for (Tag t : tags) { + if (t instanceof SetBackgroundColorTag) { + return (SetBackgroundColorTag) t; + } + } + + return null; + } + public EnableTelemetryTag getEnableTelemetry() { for (Tag t : tags) { if (t instanceof EnableTelemetryTag) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java index de78e69e8..101938446 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java @@ -34,7 +34,6 @@ import com.jpexs.decompiler.flash.helpers.BMPFile; import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.enums.ImageFormat; import com.jpexs.decompiler.flash.timeline.DepthState; @@ -173,13 +172,9 @@ public class FrameExporter { final List fframes = frames; Color backgroundColor = null; - if (settings.mode == FrameExportMode.AVI) { - for (Tag t : swf.tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sb = (SetBackgroundColorTag) t; - backgroundColor = sb.backgroundColor.toColor(); - } - } + SetBackgroundColorTag setBgColorTag = swf.getBackgroundColor(); + if (setBgColorTag != null) { + backgroundColor = setBgColorTag.backgroundColor.toColor(); } if (settings.mode == FrameExportMode.SVG) { @@ -189,7 +184,7 @@ public class FrameExporter { } final int fi = i; - final Color fbackgroundColor = backgroundColor; + final Color fbackgroundColor = null; new RetryTask(() -> { int frame = fframes.get(fi); File f = new File(foutdir + File.separator + frame + ".svg"); @@ -223,7 +218,7 @@ public class FrameExporter { } final Timeline ftim = tim; - final Color fbackgroundColor = backgroundColor; + final Color fbackgroundColor = null; final SWF fswf = swf; new RetryTask(() -> { File fcanvas = new File(foutdir + File.separator + "canvas.js"); @@ -259,11 +254,8 @@ public class FrameExporter { } sb.append("\r\n"); RGB backgroundColor1 = new RGB(255, 255, 255); - for (Tag t : fswf.tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sbgct = (SetBackgroundColorTag) t; - backgroundColor1 = sbgct.backgroundColor; - } + if (setBgColorTag != null) { + backgroundColor1 = setBgColorTag.backgroundColor; } sb.append("var backgroundColor = \"").append(backgroundColor1.toHexRGB()).append("\";\r\n"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 15b4350cb..9d5db8b79 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -103,7 +103,6 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.decompiler.flash.types.sound.MP3FRAME; import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA; import com.jpexs.decompiler.flash.types.sound.SoundFormat; -import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.SerializableImage; import com.jpexs.helpers.utf8.Utf8Helper; @@ -2688,12 +2687,11 @@ public class XFLConverter { Map characterVariables = getCharacterVariables(swf.tags); String backgroundColor = "#ffffff"; - for (Tag t : swf.tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sbc = (SetBackgroundColorTag) t; - backgroundColor = sbc.backgroundColor.toHexRGB(); - } + SetBackgroundColorTag setBgColorTag = swf.getBackgroundColor(); + if (setBgColorTag != null) { + backgroundColor = setBgColorTag.backgroundColor.toHexRGB(); } + domDocument.append(" doneCharacters = new ArrayList<>(); int frameCnt = 0; for (Tag t : subs) { + if (t instanceof FileAttributesTag || t instanceof SetBackgroundColorTag) { + continue; + } + if (t instanceof ShowFrameTag) { frameCnt++; continue; } + if (frameCnt > fn.frame) { break; } @@ -1059,11 +1070,9 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel public void showSwf(SWF swf) { Color backgroundColor = View.getDefaultBackgroundColor(); - for (Tag t : swf.tags) { - if (t instanceof SetBackgroundColorTag) { - backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor(); - break; - } + SetBackgroundColorTag setBgColorTag = swf.getBackgroundColor(); + if (setBgColorTag != null) { + backgroundColor = setBgColorTag.backgroundColor.toColor(); } if (tempFile != null) {