mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 11:25:53 +00:00
small fixes
This commit is contained in:
@@ -40,7 +40,7 @@ public class ApplicationInfo {
|
||||
static {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
|
||||
private static void loadProperties() {
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
|
||||
@@ -71,7 +71,6 @@ import com.jpexs.decompiler.flash.tags.DoInitActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
|
||||
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
|
||||
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
|
||||
@@ -170,7 +169,7 @@ import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public final class SWF implements TreeItem,Timelined {
|
||||
public final class SWF implements TreeItem, Timelined {
|
||||
|
||||
/**
|
||||
* Default version of SWF file format
|
||||
@@ -234,15 +233,15 @@ public final class SWF implements TreeItem,Timelined {
|
||||
public static final double unitDivisor = 20;
|
||||
|
||||
private Timeline timeline;
|
||||
|
||||
|
||||
@Override
|
||||
public Timeline getTimeline(){
|
||||
if(timeline == null){
|
||||
public Timeline getTimeline() {
|
||||
if (timeline == null) {
|
||||
timeline = new Timeline(this);
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all tags with specified id
|
||||
*
|
||||
@@ -2220,14 +2219,13 @@ public final class SWF implements TreeItem,Timelined {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SerializableImage frameToImageGet(Timeline timeline,int frame, RECT displayRect, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static SerializableImage frameToImageGet(Timeline timeline, int frame, RECT displayRect, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode();
|
||||
SerializableImage image = getFromCache(key);
|
||||
if (image != null) {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
if (timeline.frames.isEmpty()) {
|
||||
return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB);
|
||||
}
|
||||
@@ -2247,14 +2245,12 @@ public final class SWF implements TreeItem,Timelined {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
RECT rect = displayRect;
|
||||
for (int f=0;f<timeline.frames.size();f++) {
|
||||
for (int f = 0; f < timeline.frames.size(); f++) {
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
//Make all pixels transparent
|
||||
// Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
@@ -2278,7 +2274,7 @@ public final class SWF implements TreeItem,Timelined {
|
||||
|
||||
}
|
||||
|
||||
public static void frameToImage(Timeline timeline, int frame,RECT displayRect, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static void frameToImage(Timeline timeline, int frame, RECT displayRect, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
float unzoom = (float) SWF.unitDivisor;
|
||||
Frame frameObj = timeline.frames.get(frame);
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
@@ -2287,9 +2283,8 @@ public final class SWF implements TreeItem,Timelined {
|
||||
g.setTransform(transformation.toTransform());
|
||||
List<Clip> clips = new ArrayList<>();
|
||||
List<Shape> prevClips = new ArrayList<>();
|
||||
|
||||
|
||||
for (int i = 1; i <= timeline.getMaxDepth(); i++) {
|
||||
for (int i = 1; i <= timeline.getMaxDepth(); i++) {
|
||||
for (int c = 0; c < clips.size(); c++) {
|
||||
if (clips.get(c).clipDepth == i) {
|
||||
g.setClip(prevClips.get(c));
|
||||
@@ -2348,15 +2343,15 @@ public final class SWF implements TreeItem,Timelined {
|
||||
rect.yMax += deltaYMax * SWF.unitDivisor;
|
||||
}
|
||||
|
||||
rect.xMin = Math.max(0, rect.xMin);
|
||||
rect.yMin = Math.max(0, rect.yMin);
|
||||
|
||||
rect.xMin = Math.max(0, rect.xMin - 1);
|
||||
rect.yMin = Math.max(0, rect.yMin - 1);
|
||||
|
||||
int newWidth = (int) (rect.getWidth() / SWF.unitDivisor);
|
||||
int newHeight = (int) (rect.getHeight() / SWF.unitDivisor);
|
||||
int deltaX = (int) (rect.xMin / SWF.unitDivisor);
|
||||
int deltaY = (int) (rect.yMin / SWF.unitDivisor);
|
||||
newWidth = Math.min(image.getWidth() - deltaX, newWidth);
|
||||
newHeight = Math.min(image.getHeight() - deltaY, newHeight);
|
||||
newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 2;
|
||||
newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 2;
|
||||
|
||||
if (newWidth <= 0 || newHeight <= 0) {
|
||||
continue;
|
||||
@@ -2365,7 +2360,7 @@ public final class SWF implements TreeItem,Timelined {
|
||||
img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB);
|
||||
m.translate(-rect.xMin, -rect.yMin);
|
||||
drawMatrix.translate(rect.xMin, rect.yMin);
|
||||
|
||||
|
||||
//Make all pixels transparent
|
||||
Graphics2D gr = (Graphics2D) img.getGraphics();
|
||||
gr.setComposite(AlphaComposite.Src);
|
||||
@@ -2374,7 +2369,7 @@ public final class SWF implements TreeItem,Timelined {
|
||||
drawable.toImage(dframe, layer.ratio, timeline.swf.tags, timeline.characters, visited, img, m, clrTrans);
|
||||
} else if (drawable instanceof FontTag) {
|
||||
// only DefineFont tags
|
||||
FontTag fontTag = (FontTag) drawable;
|
||||
FontTag fontTag = (FontTag) drawable;
|
||||
img = fontTag.toImage(dframe, layer.ratio, timeline.swf.tags, timeline.characters, visited, transformation, clrTrans);
|
||||
} else {
|
||||
throw new Error("Unsupported drawable.");
|
||||
@@ -2393,7 +2388,7 @@ public final class SWF implements TreeItem,Timelined {
|
||||
drawMatrix.translateX /= unzoom;
|
||||
drawMatrix.translateY /= unzoom;
|
||||
AffineTransform trans = drawMatrix.toTransform();
|
||||
|
||||
|
||||
switch (layer.blendMode) {
|
||||
case 0:
|
||||
case 1:
|
||||
@@ -2459,7 +2454,7 @@ public final class SWF implements TreeItem,Timelined {
|
||||
prevClips.add(g.getClip());
|
||||
g.setTransform(AffineTransform.getTranslateInstance(0, 0));
|
||||
g.setClip(clip.shape);
|
||||
} else {
|
||||
} else {
|
||||
g.setTransform(trans);
|
||||
g.drawImage(img.getBufferedImage(), 0, 0, null);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Action implements GraphSourceItem {
|
||||
public int actionLength;
|
||||
public long containerSWFOffset;
|
||||
private long address;
|
||||
|
||||
|
||||
public static final String[] reservedWords = {
|
||||
"as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else",
|
||||
"extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof",
|
||||
@@ -118,7 +118,7 @@ public class Action implements GraphSourceItem {
|
||||
"with", "dynamic", "default", "final", "in"};
|
||||
|
||||
public static boolean isReservedWord(String s) {
|
||||
if(s == null){
|
||||
if (s == null) {
|
||||
return false;
|
||||
}
|
||||
for (String rw : reservedWords) {
|
||||
@@ -128,7 +128,7 @@ public class Action implements GraphSourceItem {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public long getFileAddress() {
|
||||
return containerSWFOffset + getAddress();
|
||||
}
|
||||
|
||||
@@ -39,14 +39,11 @@ public class ActionDeobfuscation {
|
||||
public HashSet<String> allVariableNamesStr = new HashSet<>();
|
||||
private final HashMap<String, Integer> typeCounts = new HashMap<>();
|
||||
|
||||
|
||||
public static final String VALID_FIRST_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
public static final String VALID_NEXT_CHARACTERS = VALID_FIRST_CHARACTERS + "0123456789";
|
||||
public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";
|
||||
public static final String FOO_JOIN_CHARACTERS = "aeiouy";
|
||||
|
||||
|
||||
|
||||
private String fooString(HashMap<String, String> deobfuscated, String orig, boolean firstUppercase, int rndSize) {
|
||||
boolean exists;
|
||||
String ret;
|
||||
|
||||
@@ -1333,6 +1333,7 @@ public final class ActionScriptLexer {
|
||||
|
||||
/**
|
||||
* Closes the input stream.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public final void yyclose() throws java.io.IOException {
|
||||
@@ -1374,7 +1375,8 @@ public final class ActionScriptLexer {
|
||||
|
||||
/**
|
||||
* Returns the current lexical state.
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final int yystate() {
|
||||
return zzLexicalState;
|
||||
@@ -1391,7 +1393,8 @@ public final class ActionScriptLexer {
|
||||
|
||||
/**
|
||||
* Returns the text matched by the current regular expression.
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final String yytext() {
|
||||
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
|
||||
@@ -1413,7 +1416,8 @@ public final class ActionScriptLexer {
|
||||
|
||||
/**
|
||||
* Returns the length of the matched text region.
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final int yylength() {
|
||||
return zzMarkedPos - zzStartRead;
|
||||
|
||||
@@ -1553,7 +1553,7 @@ public class ActionScriptParser {
|
||||
case FUNCTION:
|
||||
s = lexer.lex();
|
||||
String fname = "";
|
||||
if (s.isType(SymbolType.IDENTIFIER,SymbolGroup.GLOBALFUNC)) {
|
||||
if (s.isType(SymbolType.IDENTIFIER, SymbolGroup.GLOBALFUNC)) {
|
||||
fname = s.value.toString();
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
|
||||
@@ -43,6 +43,7 @@ import java.awt.Stroke;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.NoninvertibleTransformException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -373,7 +374,6 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
}
|
||||
|
||||
protected void finalizePath() {
|
||||
final int maxRepeat = 10; // TODO: better handle gradient repeating
|
||||
if (path != null) {
|
||||
if (fillPaint != null) {
|
||||
if (fillPaint instanceof MultipleGradientPaint) {
|
||||
@@ -383,21 +383,45 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
}
|
||||
graphics.fill(path);
|
||||
graphics.setClip(path);
|
||||
Matrix inverse = null;
|
||||
try {
|
||||
inverse = new Matrix(new AffineTransform(fillTransform).createInverse());
|
||||
} catch (NoninvertibleTransformException ex) {
|
||||
}
|
||||
|
||||
fillTransform.preConcatenate(oldAf);
|
||||
graphics.setTransform(fillTransform);
|
||||
|
||||
graphics.setPaint(fillPaint);
|
||||
graphics.fill(new java.awt.Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat));
|
||||
|
||||
if (inverse != null) {
|
||||
ExportRectangle rect = inverse.transform(new ExportRectangle(path.getBounds2D()));
|
||||
double minX = rect.xMin;
|
||||
double minY = rect.yMin;
|
||||
graphics.fill(new java.awt.Rectangle((int) minX, (int) minY, (int) (rect.xMax - minX), (int) (rect.yMax - minY)));
|
||||
}
|
||||
|
||||
graphics.setTransform(oldAf);
|
||||
graphics.setClip(null);
|
||||
} else if (fillPaint instanceof TexturePaint) {
|
||||
AffineTransform oldAf = graphics.getTransform();
|
||||
graphics.setClip(path);
|
||||
Matrix inverse = null;
|
||||
try {
|
||||
inverse = new Matrix(new AffineTransform(fillTransform).createInverse());
|
||||
} catch (NoninvertibleTransformException ex) {
|
||||
}
|
||||
|
||||
fillTransform.preConcatenate(oldAf);
|
||||
graphics.setTransform(fillTransform);
|
||||
|
||||
graphics.setPaint(fillPaint);
|
||||
graphics.fill(new java.awt.Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat));
|
||||
|
||||
if (inverse != null) {
|
||||
ExportRectangle rect = inverse.transform(new ExportRectangle(path.getBounds2D()));
|
||||
double minX = rect.xMin;
|
||||
double minY = rect.yMin;
|
||||
graphics.fill(new java.awt.Rectangle((int) minX, (int) minY, (int) (rect.xMax - minX), (int) (rect.yMax - minY)));
|
||||
}
|
||||
|
||||
graphics.setTransform(oldAf);
|
||||
graphics.setClip(null);
|
||||
} else {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,6 +44,13 @@ public class ExportRectangle {
|
||||
this.yMax = rect.Ymax;
|
||||
}
|
||||
|
||||
public ExportRectangle(Rectangle2D rect) {
|
||||
this.xMin = rect.getMinX();
|
||||
this.yMin = rect.getMinY();
|
||||
this.xMax = rect.getMaxX();
|
||||
this.yMax = rect.getMaxY();
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return xMax - xMin;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,18 @@ public class Matrix {
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix(AffineTransform transform) {
|
||||
this();
|
||||
if (transform != null) {
|
||||
scaleX = transform.getScaleX();
|
||||
rotateSkew1 = transform.getShearX();
|
||||
translateX = transform.getTranslateX();
|
||||
rotateSkew0 = transform.getShearY();
|
||||
scaleY = transform.getScaleY();
|
||||
translateY = transform.getTranslateY();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix clone() {
|
||||
Matrix mat = new Matrix();
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JColorChooser;
|
||||
@@ -63,11 +62,11 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
private SWF swf;
|
||||
private HashMap<Integer, CharacterTag> characters;
|
||||
private boolean loaded;
|
||||
|
||||
|
||||
@Override
|
||||
public void setBackground(Color bg) {
|
||||
if (label != null) {
|
||||
label.setBackground(bg);
|
||||
label.setBackground(bg);
|
||||
}
|
||||
super.setBackground(bg);
|
||||
}
|
||||
@@ -164,7 +163,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
setImage(img);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
play();
|
||||
}
|
||||
|
||||
@@ -213,16 +212,16 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
drawFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private static SerializableImage getFrame(SWF swf,int frame,DrawableTag drawable,Map<Integer,CharacterTag> characters){
|
||||
|
||||
private static SerializableImage getFrame(SWF swf, int frame, DrawableTag drawable, Map<Integer, CharacterTag> characters) {
|
||||
String key = "drawable_" + frame + "_" + drawable.hashCode();
|
||||
SerializableImage img = SWF.getFromCache(key);
|
||||
if (img == null) {
|
||||
if (drawable instanceof BoundedTag) {
|
||||
BoundedTag bounded = (BoundedTag) drawable;
|
||||
RECT rect = bounded.getRect(characters, new Stack<Integer>());
|
||||
if(rect == null){ //??? Why?
|
||||
rect = new RECT(0,0,1,1);
|
||||
if (rect == null) { //??? Why?
|
||||
rect = new RECT(0, 0, 1, 1);
|
||||
}
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
@@ -244,15 +243,15 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
private void drawFrame() {
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
Matrix mat = new Matrix();
|
||||
mat.translateX = swf.displayRect.Xmin;
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
ImageIcon icon = new ImageIcon(getFrame(swf,frame,drawable,characters).getBufferedImage());
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
ImageIcon icon = new ImageIcon(getFrame(swf, frame, drawable, characters).getBufferedImage());
|
||||
label.setIcon(icon);
|
||||
}
|
||||
|
||||
|
||||
@@ -892,10 +892,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
public void load(SWFList newSwfs, boolean first) {
|
||||
|
||||
|
||||
swfPreviewPanel.stop();
|
||||
imagePanel.stop();
|
||||
|
||||
|
||||
swfs.add(newSwfs);
|
||||
|
||||
for (SWF swf : newSwfs) {
|
||||
@@ -2467,13 +2467,13 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
int containerId = 0;
|
||||
RECT rect = swf.displayRect;
|
||||
int totalFrameCount = swf.frameCount;
|
||||
Timeline timeline=swf.getTimeline();
|
||||
Timeline timeline = swf.getTimeline();
|
||||
if (fn.getParent() instanceof DefineSpriteTag) {
|
||||
controlTags = ((DefineSpriteTag) fn.getParent()).subTags;
|
||||
containerId = ((DefineSpriteTag) fn.getParent()).spriteId;
|
||||
rect = ((DefineSpriteTag) fn.getParent()).getRect(swf.characters, new Stack<Integer>());
|
||||
totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount;
|
||||
timeline = ((DefineSpriteTag)fn.getParent()).getTimeline();
|
||||
timeline = ((DefineSpriteTag) fn.getParent()).getTimeline();
|
||||
}
|
||||
previewImagePanel.setImage(SWF.frameToImageGet(timeline, fn.getFrame() - 1, rect, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform()));
|
||||
} else if (((tagObj instanceof FrameNodeItem) && ((FrameNodeItem) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
|
||||
@@ -2907,7 +2907,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
textValue.setText(textTag.getFormattedText());
|
||||
textValue.setCaretPosition(0);
|
||||
}
|
||||
|
||||
|
||||
public void expandSwfNodes() {
|
||||
TreeModel model = tagTree.getModel();
|
||||
Object node = model.getRoot();
|
||||
|
||||
@@ -113,7 +113,7 @@ public class SWFPreviewPanel extends JPanel implements FlashDisplay {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawFrame() {
|
||||
pan.setImage(frameImages.get(frame));
|
||||
}
|
||||
|
||||
@@ -42,13 +42,11 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -47,13 +47,11 @@ import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -760,7 +760,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
if (border) {
|
||||
// todo: how to get the border and fill colors?
|
||||
// border is always black, fill color is always white?
|
||||
RGB borderColor = new RGBA(Color.black);
|
||||
RGB fillColor = new RGBA(Color.white);
|
||||
drawBorder(swf, image, borderColor, fillColor, getRect(characters, visited), getTextMatrix(), transformation, colorTransform);
|
||||
@@ -853,7 +853,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove spaces after last word
|
||||
for (List<SameStyleTextRecord> line : lines) {
|
||||
boolean removed = true;
|
||||
@@ -865,17 +865,17 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
if (line.size() > 0) {
|
||||
SameStyleTextRecord lastRecord = line.get(line.size() - 1);
|
||||
while (lastRecord.glyphEntries.size() > 0 &&
|
||||
Character.isWhitespace(lastRecord.glyphEntries.get(lastRecord.glyphEntries.size() - 1).character)) {
|
||||
lastRecord.glyphEntries.remove(lastRecord.glyphEntries.size() -1);
|
||||
while (lastRecord.glyphEntries.size() > 0
|
||||
&& Character.isWhitespace(lastRecord.glyphEntries.get(lastRecord.glyphEntries.size() - 1).character)) {
|
||||
lastRecord.glyphEntries.remove(lastRecord.glyphEntries.size() - 1);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
textModel.calculateTexWidths();
|
||||
|
||||
|
||||
List<TEXTRECORD> allTextRecords = new ArrayList<>();
|
||||
int yOffset = 0;
|
||||
for (List<SameStyleTextRecord> line : lines) {
|
||||
@@ -946,7 +946,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return new Point(bounds.Xmin / SWF.unitDivisor, bounds.Ymin / SWF.unitDivisor);
|
||||
|
||||
@@ -251,7 +251,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
shape.shapeRecords.add(new EndShapeRecord());
|
||||
BitmapExporter.exportTo(swf, shape, null, image, mat, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
public static void staticTextToImage(SWF swf, Map<Integer, CharacterTag> characters, List<TEXTRECORD> textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation, ColorTransform colorTransform) {
|
||||
Color textColor = new Color(0, 0, 0);
|
||||
FontTag font = null;
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.tags.dynamictext;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CharacterWithStyle {
|
||||
|
||||
|
||||
public char character;
|
||||
|
||||
public TextStyle style;
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
public class DynamicTextModel {
|
||||
|
||||
public List<Paragraph> paragraphs = new ArrayList<>();
|
||||
|
||||
|
||||
private Paragraph paragraph;
|
||||
public TextStyle style;
|
||||
public int width;
|
||||
@@ -36,18 +36,18 @@ public class DynamicTextModel {
|
||||
public DynamicTextModel() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addGlyph(char character, GLYPHENTRY glyphEntry) {
|
||||
|
||||
|
||||
if (paragraph == null) {
|
||||
paragraph = new Paragraph(this);
|
||||
paragraphs.add(paragraph);
|
||||
}
|
||||
paragraph.addGlyph(character, glyphEntry);
|
||||
}
|
||||
|
||||
|
||||
public void newParagraph() {
|
||||
|
||||
|
||||
paragraph = null;
|
||||
}
|
||||
|
||||
@@ -59,14 +59,14 @@ public class DynamicTextModel {
|
||||
}
|
||||
|
||||
public void newRecord() {
|
||||
|
||||
|
||||
if (paragraph != null) {
|
||||
paragraph.newRecord();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int calculateTexWidths() {
|
||||
|
||||
|
||||
int width = 0;
|
||||
for (Paragraph p : paragraphs) {
|
||||
width += p.calculateTexWidths();
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.jpexs.decompiler.flash.types.GLYPHENTRY;
|
||||
public class GlyphCharacter {
|
||||
|
||||
public GLYPHENTRY glyphEntry;
|
||||
|
||||
|
||||
public char character;
|
||||
|
||||
|
||||
public GlyphCharacter(char character, GLYPHENTRY glyphEntry) {
|
||||
|
||||
|
||||
this.character = character;
|
||||
this.glyphEntry = glyphEntry;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Paragraph {
|
||||
|
||||
|
||||
public List<Word> words = new ArrayList<>();
|
||||
|
||||
private Word word;
|
||||
@@ -39,7 +39,7 @@ public class Paragraph {
|
||||
}
|
||||
|
||||
public void addGlyph(char character, GLYPHENTRY glyphEntry) {
|
||||
|
||||
|
||||
if (word == null) {
|
||||
word = new Word(model);
|
||||
words.add(word);
|
||||
@@ -53,14 +53,14 @@ public class Paragraph {
|
||||
}
|
||||
|
||||
public void newRecord() {
|
||||
|
||||
|
||||
if (word != null) {
|
||||
word.newRecord();
|
||||
}
|
||||
}
|
||||
|
||||
public int calculateTexWidths() {
|
||||
|
||||
|
||||
int width = 0;
|
||||
for (Word w : words) {
|
||||
width += w.calculateTexWidths();
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SameStyleTextRecord {
|
||||
|
||||
|
||||
public TextStyle style;
|
||||
|
||||
public int xOffset;
|
||||
@@ -35,7 +35,7 @@ public class SameStyleTextRecord {
|
||||
public List<GlyphCharacter> glyphEntries = new ArrayList<>();
|
||||
|
||||
public int calculateTexWidths() {
|
||||
|
||||
|
||||
int width = 0;
|
||||
for (GlyphCharacter gc : glyphEntries) {
|
||||
width += gc.glyphEntry.glyphAdvance;
|
||||
|
||||
@@ -25,9 +25,9 @@ import com.jpexs.decompiler.flash.types.RGBA;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TextStyle {
|
||||
|
||||
|
||||
public FontTag font;
|
||||
|
||||
|
||||
public int fontHeight;
|
||||
|
||||
public int fontLeading;
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Word {
|
||||
|
||||
|
||||
public List<SameStyleTextRecord> records = new ArrayList<>();
|
||||
|
||||
|
||||
private SameStyleTextRecord record;
|
||||
private final DynamicTextModel model;
|
||||
public int width;
|
||||
@@ -36,9 +36,9 @@ public class Word {
|
||||
public Word(DynamicTextModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
|
||||
public void addGlyph(char character, GLYPHENTRY glyphEntry) {
|
||||
|
||||
|
||||
if (record == null) {
|
||||
record = new SameStyleTextRecord();
|
||||
record.style = model.style;
|
||||
@@ -48,12 +48,12 @@ public class Word {
|
||||
}
|
||||
|
||||
public void newRecord() {
|
||||
|
||||
|
||||
record = null;
|
||||
}
|
||||
|
||||
public int calculateTexWidths() {
|
||||
|
||||
|
||||
int width = 0;
|
||||
for (SameStyleTextRecord r : records) {
|
||||
width += r.calculateTexWidths();
|
||||
|
||||
@@ -62,6 +62,6 @@ public class DepthState {
|
||||
clipActions = obj.clipActions;
|
||||
ratio = obj.ratio;
|
||||
clipDepth = obj.clipDepth;
|
||||
time = obj.time+1;
|
||||
time = obj.time + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Frame {
|
||||
|
||||
public Map<Integer, DepthState> layers = new HashMap<>();
|
||||
public DoActionTag action;
|
||||
public RGB backgroundColor = new RGBA(0,0,0,0);
|
||||
public RGB backgroundColor = new RGBA(0, 0, 0, 0);
|
||||
|
||||
public Frame() {
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Timeline {
|
||||
|
||||
public List<Frame> frames = new ArrayList<>();
|
||||
public int id;
|
||||
public Map<Integer,CharacterTag> characters = new HashMap<>();
|
||||
public Map<Integer, CharacterTag> characters = new HashMap<>();
|
||||
public SWF swf;
|
||||
|
||||
public Timeline() {
|
||||
@@ -63,23 +63,23 @@ public class Timeline {
|
||||
return frames.size();
|
||||
}
|
||||
|
||||
public Timeline(SWF swf){
|
||||
this(swf,swf.tags,0);
|
||||
public Timeline(SWF swf) {
|
||||
this(swf, swf.tags, 0);
|
||||
}
|
||||
|
||||
public Timeline(SWF swf,List<Tag> tags,int id) {
|
||||
this.id =id;
|
||||
|
||||
public Timeline(SWF swf, List<Tag> tags, int id) {
|
||||
this.id = id;
|
||||
this.swf = swf;
|
||||
Frame frame = new Frame();
|
||||
for (Tag t : swf.tags) {
|
||||
if(t instanceof CharacterTag){
|
||||
CharacterTag c=(CharacterTag)t;
|
||||
if (t instanceof CharacterTag) {
|
||||
CharacterTag c = (CharacterTag) t;
|
||||
characters.put(c.getCharacterId(), c);
|
||||
}
|
||||
}
|
||||
for (Tag t : tags) {
|
||||
if(t instanceof SetBackgroundColorTag){
|
||||
frame.backgroundColor = ((SetBackgroundColorTag)t).backgroundColor;
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
frame.backgroundColor = ((SetBackgroundColorTag) t).backgroundColor;
|
||||
}
|
||||
if (t instanceof PlaceObjectTypeTag) {
|
||||
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
|
||||
@@ -126,7 +126,7 @@ public class Timeline {
|
||||
fl.ratio = ratio2;
|
||||
}
|
||||
int clipDepth2 = po.getClipDepth();
|
||||
if(clipDepth2>-1){
|
||||
if (clipDepth2 > -1) {
|
||||
fl.clipDepth = clipDepth2;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.timeline;
|
||||
|
||||
/**
|
||||
@@ -22,5 +21,6 @@ package com.jpexs.decompiler.flash.timeline;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface Timelined {
|
||||
|
||||
public Timeline getTimeline();
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
|
||||
private long hdrPos;
|
||||
|
||||
//Constructor for Generic tag editor. TODO:Handle this somehow better
|
||||
public CLIPACTIONRECORD(){
|
||||
public CLIPACTIONRECORD() {
|
||||
swf = null;
|
||||
eventFlags = new CLIPEVENTFLAGS();
|
||||
actionBytes = new byte[0];
|
||||
hdrPos = 0;
|
||||
}
|
||||
|
||||
|
||||
public CLIPACTIONRECORD(SWF swf, InputStream is, long pos) throws IOException {
|
||||
this.swf = swf;
|
||||
SWFInputStream sis = new SWFInputStream(is, swf.version);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class BEVELFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class BLURFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class COLORMATRIXFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return 0;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class CONVOLUTIONFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return 0;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class DROPSHADOWFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class FILTER implements Serializable {
|
||||
}
|
||||
|
||||
public abstract SerializableImage apply(SerializableImage src);
|
||||
|
||||
|
||||
public abstract double getDeltaX();
|
||||
|
||||
public abstract double getDeltaY();
|
||||
|
||||
@@ -250,7 +250,7 @@ public class Filtering {
|
||||
public static SerializableImage gradientBevel(SerializableImage src, Color[] colors, float[] ratios, int blurX, int blurY, float strength, int type, float angle, float distance, boolean knockout, int iterations) {
|
||||
return new SerializableImage(gradientBevel(src.getBufferedImage(), colors, ratios, blurX, blurY, strength, type, angle, distance, knockout, iterations));
|
||||
}
|
||||
|
||||
|
||||
private static BufferedImage gradientBevel(BufferedImage src, Color[] colors, float[] ratios, int blurX, int blurY, float strength, int type, float angle, float distance, boolean knockout, int iterations) {
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -332,7 +332,7 @@ public class Filtering {
|
||||
public static SerializableImage gradientGlow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color[] colors, float[] ratios, int type, int iterations, float strength, boolean knockout) {
|
||||
return new SerializableImage(gradientGlow(src.getBufferedImage(), blurX, blurY, angle, distance, colors, ratios, type, iterations, strength, knockout));
|
||||
}
|
||||
|
||||
|
||||
private static BufferedImage gradientGlow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color[] colors, float[] ratios, int type, int iterations, float strength, boolean knockout) {
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class GLOWFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
@@ -122,7 +122,7 @@ public class GRADIENTBEVELFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class GRADIENTGLOWFILTER extends FILTER {
|
||||
public double getDeltaX() {
|
||||
return blurX;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDeltaY() {
|
||||
return blurY;
|
||||
|
||||
Reference in New Issue
Block a user