mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-19 16:31:57 +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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user