diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index 79009ba0a..6e7d7a1b7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -1441,7 +1441,7 @@ public class SWFInputStream implements AutoCloseable { } } } catch (IOException ex) { - logger.log(Level.SEVERE, "Error during tag reading", ex); + logger.log(Level.SEVERE, "Error during tag reading. ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex); ret = new TagStub(swf, tag.getId(), "ErrorTag", data, null); } ret.forceWriteAsLong = tag.forceWriteAsLong; @@ -2631,7 +2631,7 @@ public class SWFInputStream implements AutoCloseable { } if (stateNewStyles) { if (morphShape) { - // This should never happen + // This should never happen in a valid SWF throw new IOException("MorphShape should not have new styles."); } else { scr.fillStyles = readFILLSTYLEARRAY(shapeNum, "fillStyles"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 516b10fce..f96b28a65 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -1376,7 +1376,7 @@ public class SWFOutputStream extends OutputStream { scr.numFillBits = getNeededBitsU(scr.fillStyles.fillStyles.length); scr.numLineBits = getNeededBitsU(scr.lineStyles.lineStyles.length); fillBits = scr.numFillBits; - fillBits = scr.numLineBits; + lineBits = scr.numLineBits; writeUB(4, scr.numFillBits); writeUB(4, scr.numLineBits); } @@ -1501,7 +1501,8 @@ public class SWFOutputStream extends OutputStream { writeRGBA(value.endColor); } if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) - || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT) + || (value.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT)) { writeMatrix(value.startGradientMatrix); writeMatrix(value.endGradientMatrix); } @@ -1509,6 +1510,9 @@ public class SWFOutputStream extends OutputStream { || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { writeMORPHGRADIENT(value.gradient, shapeNum); } + if (value.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT) { + writeMORPHFOCALGRADIENT((MORPHFOCALGRADIENT) value.gradient, shapeNum); + } if ((value.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) || (value.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java index 27978bfcb..e5844d528 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.configuration.Configuration; @@ -67,18 +68,20 @@ public class ExportTest { @DataProvider(name = "swfFiles") public Object[][] createData() { File dir = new File(TESTDATADIR); - if (!dir.exists()) { - return new Object[0][0]; + File[] files = new File[0]; + if (dir.exists()) { + files = dir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.toLowerCase().endsWith(".swf"); + } + }); } - File[] files = dir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.toLowerCase().endsWith(".swf"); - } - }); - Object[][] ret = new Object[files.length][1]; - for (int i = 0; i < files.length; i++) { - ret[i][0] = files[i]; + Object[][] ret = new Object[files.length + 2][1]; + ret[0][0] = new File(TESTDATADIR + File.separator + "../as2/as2.swf"); + ret[1][0] = new File(TESTDATADIR + File.separator + "../as3/as3.swf"); + for (int f = 0; f < files.length; f++) { + ret[f + 2][0] = files[f]; } return ret; } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java index acdf17dea..25838d4fa 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java @@ -30,6 +30,8 @@ import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.TagStub; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.TranslateException; @@ -148,6 +150,27 @@ public class RecompileTest { } } + @Test(dataProvider = "provideFiles") + public void testTagEditing(String filename) throws IOException, InterruptedException { + try { + SWF swf = new SWF(new BufferedInputStream(new FileInputStream(TESTDATADIR + File.separator + filename)), false); + for (Tag tag : swf.tags) { + if (!(tag instanceof TagStub)) { + byte[] data = tag.getData(); + SWFInputStream tagDataStream = new SWFInputStream(swf, data, tag.getDataPos(), data.length); + TagStub copy = new TagStub(swf, tag.getId(), "Unresolved", tag.getOriginalRange(), tagDataStream); + copy.forceWriteAsLong = tag.forceWriteAsLong; + Tag tag2 = SWFInputStream.resolveTag(copy, 0, false, true, false); + if (tag2 instanceof TagStub) { + fail("Recompile failed. Tag: " + tag.getId() + " " + tag.getName()); + } + } + } + } catch (Exception ex) { + // ignore + } + } + @DataProvider(name = "provideFiles") public Object[][] provideFiles() { File dir = new File(TESTDATADIR);