mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-07 19:58:52 +00:00
updateTextBounds fix
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -664,6 +664,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (actionPanel != null) {
|
||||
actionPanel.clearSource();
|
||||
}
|
||||
previewPanel.clear();
|
||||
updateUi();
|
||||
refreshTree();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user