diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 5c6daccb8..93bc2b245 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -551,6 +551,15 @@ public class DefineText2Tag extends TextTag { @Override public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { staticTextToImage(swf, textRecords, 2, image, getTextMatrix(), transformation, colorTransform); + /*try { + DefineText2Tag originalTag = (DefineText2Tag) getOriginalTag(); + if (isModified()) { + originalTag.toImage(frame, time, ratio, stateUnderCursor, mouseButton, image, transformation, new ConstantColorColorTransform(0xFFC0C0C0)); + } + staticTextToImage(swf, textRecords, 2, image, getTextMatrix(), transformation, new ConstantColorColorTransform(0xFF000000)); + } catch (InterruptedException | IOException ex) { + Logger.getLogger(DefineText2Tag.class.getName()).log(Level.SEVERE, null, ex); + }*/ } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 13466414c..28a44e17f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -570,6 +570,15 @@ public class DefineTextTag extends TextTag { @Override public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { staticTextToImage(swf, textRecords, 1, image, getTextMatrix(), transformation, colorTransform); + /*try { + DefineTextTag originalTag = (DefineTextTag) getOriginalTag(); + if (isModified()) { + originalTag.toImage(frame, time, ratio, stateUnderCursor, mouseButton, image, transformation, new ConstantColorColorTransform(0xFFC0C0C0)); + } + staticTextToImage(swf, textRecords, 1, image, getTextMatrix(), transformation, new ConstantColorColorTransform(0xFF000000)); + } catch (InterruptedException | IOException ex) { + Logger.getLogger(DefineTextTag.class.getName()).log(Level.SEVERE, null, ex); + }*/ } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index 3f06f5682..185b687d7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -346,6 +346,14 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { return SWFInputStream.resolveTag(copy, 0, false, true, false); } + public Tag getOriginalTag() throws InterruptedException, IOException { + byte[] data = getOriginalData(); + SWFInputStream tagDataStream = new SWFInputStream(swf, data, getDataPos(), data.length); + TagStub copy = new TagStub(swf, getId(), "Unresolved", getOriginalRange(), tagDataStream); + copy.forceWriteAsLong = forceWriteAsLong; + return SWFInputStream.resolveTag(copy, 0, false, true, false); + } + /** * Returns string representation of the object * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 89e352dad..a21728be8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -354,14 +354,16 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { // shapeNum: 1 SHAPE shape = glyphs.get(entry.glyphIndex); RECT glyphBounds = shape.getBounds(); - ExportRectangle rect = mat.transform(new ExportRectangle(glyphBounds)); - if (result == null) { - result = rect; - } else { - result.xMin = Math.min(result.xMin, rect.xMin); - result.yMin = Math.min(result.yMin, rect.yMin); - result.xMax = Math.max(result.xMax, rect.xMax); - result.yMax = Math.max(result.yMax, rect.yMax); + if (!shape.shapeRecords.isEmpty() && !(shape.shapeRecords.get(0) instanceof EndShapeRecord)) { + ExportRectangle rect = mat.transform(new ExportRectangle(glyphBounds)); + if (result == null) { + result = rect; + } else { + result.xMin = Math.min(result.xMin, rect.xMin); + result.yMin = Math.min(result.yMin, rect.yMin); + result.xMax = Math.max(result.xMax, rect.xMax); + result.yMax = Math.max(result.yMax, rect.yMax); + } } x += entry.glyphAdvance; } @@ -375,20 +377,22 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { TextImportResizeTextBoundsMode resizeMode = Configuration.textImportResizeTextBoundsMode.get(); if (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_ONLY) || resizeMode.equals(TextImportResizeTextBoundsMode.GROW_AND_SHRINK)) { ExportRectangle newBounds = calculateTextBounds(); - int xMin = (int) Math.floor(newBounds.xMin); - int yMin = (int) Math.floor(newBounds.yMin); - int xMax = (int) Math.ceil(newBounds.xMax); - int yMax = (int) Math.ceil(newBounds.yMax); - if (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_ONLY)) { - textBounds.Xmin = Math.min(xMin, textBounds.Xmin); - textBounds.Ymin = Math.min(yMin, textBounds.Ymin); - textBounds.Xmax = Math.max(xMax, textBounds.Xmax); - textBounds.Ymax = Math.max(yMax, textBounds.Ymax); - } else if (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_AND_SHRINK)) { - textBounds.Xmin = xMin; - textBounds.Ymin = yMin; - textBounds.Xmax = xMax; - textBounds.Ymax = yMax; + if (newBounds != null) { + int xMin = (int) Math.floor(newBounds.xMin); + int yMin = (int) Math.floor(newBounds.yMin); + int xMax = (int) Math.ceil(newBounds.xMax); + int yMax = (int) Math.ceil(newBounds.yMax); + if (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_ONLY)) { + textBounds.Xmin = Math.min(xMin, textBounds.Xmin); + textBounds.Ymin = Math.min(yMin, textBounds.Ymin); + textBounds.Xmax = Math.max(xMax, textBounds.Xmax); + textBounds.Ymax = Math.max(yMax, textBounds.Ymax); + } else if (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_AND_SHRINK)) { + textBounds.Xmin = xMin; + textBounds.Ymin = yMin; + textBounds.Xmax = xMax; + textBounds.Ymax = yMax; + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ConstantColorColorTransform.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ConstantColorColorTransform.java new file mode 100644 index 000000000..b73e01ca4 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ConstantColorColorTransform.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.types; + +/** + * + * @author JPEXS + */ +public class ConstantColorColorTransform extends ColorTransform { + + private final int color; + + public ConstantColorColorTransform(int color) { + this.color = color; + } + + @Override + public int apply(int color) { + return this.color; + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index bceb053dd..60b30d1b0 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.timeline.Timeline; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.ConstantColorColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.helpers.SerializableImage; @@ -562,22 +563,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis Matrix m = new Matrix(); m.translate(-rect.Xmin * zoomDouble, -rect.Ymin * zoomDouble); m.scale(zoomDouble); - textTag.toImage(0, 0, 0, null, 0, image, m, new ColorTransform() { - - @Override - public int apply(int color) { - return 0xFFC0C0C0; - } - }); + textTag.toImage(0, 0, 0, null, 0, image, m, new ConstantColorColorTransform(0xFFC0C0C0)); if (newTextTag != null) { - newTextTag.toImage(0, 0, 0, null, 0, image, m, new ColorTransform() { - - @Override - public int apply(int color) { - return 0xFF000000; - } - }); + newTextTag.toImage(0, 0, 0, null, 0, image, m, new ConstantColorColorTransform(0xFF000000)); } iconPanel.setImg(image); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 2130ccc79..06bf6c1ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -481,9 +481,6 @@ public class Main { public static boolean reloadSWFs() { CancellableWorker.cancelBackgroundThreads(); - if (mainFrame != null) { - mainFrame.getPanel().closeAll(); - } if (Main.sourceInfos.isEmpty()) { Helper.freeMem(); showModeFrame(); @@ -520,6 +517,7 @@ public class Main { } if (mainFrame != null) { mainFrame.setVisible(false); + mainFrame.getPanel().closeAll(); mainFrame = null; } FontTag.reload(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 33e5688fa..a41dc532e 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -664,6 +664,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (actionPanel != null) { actionPanel.clearSource(); } + previewPanel.clear(); updateUi(); refreshTree(); }