viewer fixes

This commit is contained in:
Jindra Petk
2013-06-02 21:24:06 +02:00
parent 8a2f881227
commit 201f9a40bd
6 changed files with 100 additions and 29 deletions

View File

@@ -29,9 +29,7 @@ public class Configuration {
public static final boolean DISPLAY_FILENAME = true;
public static boolean DEBUG_COPY = false;
public static boolean dump_tags = false;
/**
* Debug mode = throwing an error when comparing original file and
* recompiled
@@ -54,14 +52,12 @@ public class Configuration {
* Find latest constant pool in the code
*/
public static final boolean LATEST_CONSTANTPOOL_HACK = false;
/**
* Limit of code subs (for obfuscated code)
*/
public static final int SUBLIMITER = 500;
//using parameter names in decompiling may cause problems because oficial programs like Flash CS 5.5 inserts wrong parameter names indices
public static final boolean PARAM_NAMES_ENABLE = false;
private static HashMap<String, Object> config = new HashMap<String, Object>();
/**
* List of replacements

View File

@@ -1384,6 +1384,17 @@ public class SWF {
ret.Xmax = rect.Xmax;
ret.Ymin = rect.Ymin;
ret.Ymax = rect.Ymax;
if (ret.Xmax <= 0) {
ret.Xmax = ret.getWidth();
ret.Xmin = 0;
}
if (ret.Ymax <= 0) {
ret.Ymax = ret.getHeight();
ret.Ymin = 0;
}
if (ret.Xmin < 0) {
ret.Xmax += (-ret.Xmin);
ret.Xmin = 0;
@@ -1392,11 +1403,19 @@ public class SWF {
ret.Ymax += (-ret.Ymin);
ret.Ymin = 0;
}
if (ret.getWidth() < 1 || ret.getHeight() < 1) {
ret.Xmin = 0;
ret.Ymin = 0;
ret.Xmax = 20;
ret.Ymax = 20;
}
return ret;
}
public static BufferedImage frameToImage(int containerId, int maxDepth, HashMap<Integer, Layer> layers, Color backgroundColor, HashMap<Integer, CharacterTag> characters, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect) {
displayRect = fixRect(displayRect);
String key = "frame_" + frame + "_" + containerId;
if (cache.contains(key)) {
return ((CachedImage) cache.get(key)).getImage();

View File

@@ -97,12 +97,11 @@ public class Main {
public static boolean isCommandLineMode() {
return commandLineMode;
}
/**
* Dump tags to stdout
*/
//
public static String getFileTitle() {
if (maskURL != null) {
return maskURL;

View File

@@ -66,6 +66,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
private RECT getCharacterBounds(HashMap<Integer, CharacterTag> allCharacters, Set<Integer> characters) {
RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE);
boolean foundSomething = false;
for (int c : characters) {
Tag t = allCharacters.get(c);
RECT r = null;
@@ -73,12 +74,16 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
r = ((BoundedTag) t).getRect(allCharacters);
}
if (r != null) {
foundSomething = true;
ret.Xmin = Math.min(r.Xmin, ret.Xmin);
ret.Ymin = Math.min(r.Ymin, ret.Ymin);
ret.Xmax = Math.max(r.Xmax, ret.Xmax);
ret.Ymax = Math.max(r.Ymax, ret.Ymax);
}
}
if (!foundSomething) {
return new RECT();
}
return ret;
}
@@ -86,6 +91,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
public RECT getRect(HashMap<Integer, CharacterTag> characters) {
RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE);
HashMap<Integer, Integer> depthMap = new HashMap<Integer, Integer>();
boolean foundSomething = false;
for (Tag t : subTags) {
MATRIX m = null;
int characterId = -1;
@@ -129,6 +135,10 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
ret.Ymin = Math.min(r.Ymin, ret.Ymin);
ret.Xmax = Math.max(r.Xmax, ret.Xmax);
ret.Ymax = Math.max(r.Ymax, ret.Ymax);
foundSomething = true;
}
if (!foundSomething) {
return new RECT();
}
return ret;
}

View File

@@ -93,6 +93,11 @@ public class GRADIENTBEVELFILTER extends FILTER {
colors.add(gradientColors[i].toColor());
ratios.add(gradientRatio[i] / 255f);
}
float ratiosAr[] = new float[ratios.size()];
for (int i = 0; i < ratios.size(); i++) {
ratiosAr[i] = ratios.get(i);
}
Color colorsArr[] = colors.toArray(new Color[colors.size()]);
int type = Filtering.INNER;
if (onTop && !innerShadow) {
type = Filtering.FULL;
@@ -100,10 +105,6 @@ public class GRADIENTBEVELFILTER extends FILTER {
type = Filtering.OUTER;
}
float ratiosAr[] = new float[ratios.size()];
for (int i = 0; i < ratios.size(); i++) {
ratiosAr[i] = ratios.get(i);
}
return Filtering.gradientBevel(src, colors.toArray(new Color[colors.size()]), ratiosAr, (int) blurX, (int) blurY, strength, type, (int) (angle * 180 / Math.PI), (float) distance, knockout, passes);
return Filtering.gradientBevel(src, colorsArr, ratiosAr, (int) blurX, (int) blurY, strength, type, (int) (angle * 180 / Math.PI), (float) distance, knockout, passes);
}
}

View File

@@ -164,16 +164,28 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
}
break;
case FILLSTYLE.FOCAL_RADIAL_GRADIENT:
float focRadFractions[] = new float[fillStyle0.focalGradient.gradientRecords.length];
Color focRadColors[] = new Color[fillStyle0.focalGradient.gradientRecords.length];
for (int i = 0; i < fillStyle0.focalGradient.gradientRecords.length; i++) {
focRadFractions[i] = fillStyle0.focalGradient.gradientRecords[i].getRatioFloat();
List<Color> colorsFocRad = new ArrayList<Color>();
List<Float> ratiosFocRad = new ArrayList<Float>();
for (int i = 0; i < fillStyle0.gradient.gradientRecords.length; i++) {
if ((i > 0) && (fillStyle0.gradient.gradientRecords[i - 1].ratio == fillStyle0.gradient.gradientRecords[i].ratio)) {
continue;
}
ratiosFocRad.add(fillStyle0.gradient.gradientRecords[i].getRatioFloat());
if (shapeNum >= 3) {
focRadColors[i] = new Color(fillStyle0.focalGradient.gradientRecords[i].colorA.red, fillStyle0.focalGradient.gradientRecords[i].colorA.green, fillStyle0.focalGradient.gradientRecords[i].colorA.blue, fillStyle0.focalGradient.gradientRecords[i].colorA.alpha);
colorsFocRad.add(new Color(fillStyle0.gradient.gradientRecords[i].colorA.red, fillStyle0.gradient.gradientRecords[i].colorA.green, fillStyle0.gradient.gradientRecords[i].colorA.blue, fillStyle0.gradient.gradientRecords[i].colorA.alpha));
} else {
focRadColors[i] = new Color(fillStyle0.focalGradient.gradientRecords[i].color.red, fillStyle0.focalGradient.gradientRecords[i].color.green, fillStyle0.focalGradient.gradientRecords[i].color.blue);
colorsFocRad.add(new Color(fillStyle0.gradient.gradientRecords[i].color.red, fillStyle0.gradient.gradientRecords[i].color.green, fillStyle0.gradient.gradientRecords[i].color.blue));
}
}
float focRadFractions[] = new float[ratiosFocRad.size()];
for (int i = 0; i < ratiosFocRad.size(); i++) {
focRadFractions[i] = ratiosFocRad.get(i);
}
Color focRadColors[] = colorsFocRad.toArray(new Color[colorsFocRad.size()]);
RGB focEndColor = fillStyle0.focalGradient.gradientRecords[fillStyle0.focalGradient.gradientRecords.length - 1].color;
RGBA focEndColorA = fillStyle0.focalGradient.gradientRecords[fillStyle0.focalGradient.gradientRecords.length - 1].colorA;
if (shapeNum >= 3) {
@@ -204,16 +216,28 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
g.setClip(null);
return;
case FILLSTYLE.RADIAL_GRADIENT:
float radFractions[] = new float[fillStyle0.gradient.gradientRecords.length];
Color radColors[] = new Color[fillStyle0.gradient.gradientRecords.length];
List<Color> colorsRad = new ArrayList<Color>();
List<Float> ratiosRad = new ArrayList<Float>();
for (int i = 0; i < fillStyle0.gradient.gradientRecords.length; i++) {
radFractions[i] = fillStyle0.gradient.gradientRecords[i].getRatioFloat();
if ((i > 0) && (fillStyle0.gradient.gradientRecords[i - 1].ratio == fillStyle0.gradient.gradientRecords[i].ratio)) {
continue;
}
ratiosRad.add(fillStyle0.gradient.gradientRecords[i].getRatioFloat());
if (shapeNum >= 3) {
radColors[i] = new Color(fillStyle0.gradient.gradientRecords[i].colorA.red, fillStyle0.gradient.gradientRecords[i].colorA.green, fillStyle0.gradient.gradientRecords[i].colorA.blue, fillStyle0.gradient.gradientRecords[i].colorA.alpha);
colorsRad.add(new Color(fillStyle0.gradient.gradientRecords[i].colorA.red, fillStyle0.gradient.gradientRecords[i].colorA.green, fillStyle0.gradient.gradientRecords[i].colorA.blue, fillStyle0.gradient.gradientRecords[i].colorA.alpha));
} else {
radColors[i] = new Color(fillStyle0.gradient.gradientRecords[i].color.red, fillStyle0.gradient.gradientRecords[i].color.green, fillStyle0.gradient.gradientRecords[i].color.blue);
colorsRad.add(new Color(fillStyle0.gradient.gradientRecords[i].color.red, fillStyle0.gradient.gradientRecords[i].color.green, fillStyle0.gradient.gradientRecords[i].color.blue));
}
}
float ratiosRadAr[] = new float[ratiosRad.size()];
for (int i = 0; i < ratiosRad.size(); i++) {
ratiosRadAr[i] = ratiosRad.get(i);
}
Color colorsRadArr[] = colorsRad.toArray(new Color[colorsRad.size()]);
RGB endColor = fillStyle0.gradient.gradientRecords[fillStyle0.gradient.gradientRecords.length - 1].color;
RGBA endColorA = fillStyle0.gradient.gradientRecords[fillStyle0.gradient.gradientRecords.length - 1].colorA;
if (shapeNum >= 3) {
@@ -238,22 +262,34 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
cmRad = CycleMethod.REPEAT;
}
g.setPaint(new RadialGradientPaint(new Point(0, 0), 16384, radFractions, radColors, cmRad));
g.setPaint(new RadialGradientPaint(new Point(0, 0), 16384, ratiosRadAr, colorsRadArr, cmRad));
g.fill(new Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat));
g.setTransform(oldAf);
g.setClip(null);
return;
case FILLSTYLE.LINEAR_GRADIENT:
float fractions[] = new float[fillStyle0.gradient.gradientRecords.length];
Color colors[] = new Color[fillStyle0.gradient.gradientRecords.length];
List<Color> colors = new ArrayList<Color>();
List<Float> ratios = new ArrayList<Float>();
for (int i = 0; i < fillStyle0.gradient.gradientRecords.length; i++) {
fractions[i] = fillStyle0.gradient.gradientRecords[i].getRatioFloat();
if ((i > 0) && (fillStyle0.gradient.gradientRecords[i - 1].ratio == fillStyle0.gradient.gradientRecords[i].ratio)) {
continue;
}
ratios.add(fillStyle0.gradient.gradientRecords[i].getRatioFloat());
if (shapeNum >= 3) {
colors[i] = new Color(fillStyle0.gradient.gradientRecords[i].colorA.red, fillStyle0.gradient.gradientRecords[i].colorA.green, fillStyle0.gradient.gradientRecords[i].colorA.blue, fillStyle0.gradient.gradientRecords[i].colorA.alpha);
colors.add(new Color(fillStyle0.gradient.gradientRecords[i].colorA.red, fillStyle0.gradient.gradientRecords[i].colorA.green, fillStyle0.gradient.gradientRecords[i].colorA.blue, fillStyle0.gradient.gradientRecords[i].colorA.alpha));
} else {
colors[i] = new Color(fillStyle0.gradient.gradientRecords[i].color.red, fillStyle0.gradient.gradientRecords[i].color.green, fillStyle0.gradient.gradientRecords[i].color.blue);
colors.add(new Color(fillStyle0.gradient.gradientRecords[i].color.red, fillStyle0.gradient.gradientRecords[i].color.green, fillStyle0.gradient.gradientRecords[i].color.blue));
}
}
float ratiosAr[] = new float[ratios.size()];
for (int i = 0; i < ratios.size(); i++) {
ratiosAr[i] = ratios.get(i);
}
Color colorsArr[] = colors.toArray(new Color[colors.size()]);
GeneralPath pathLin = toGeneralPath(startX, startY);
g.fill(pathLin);
g.setClip(pathLin);
@@ -272,7 +308,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
}
g.setPaint(new LinearGradientPaint(new Point(-16384, 0), new Point(16384, 0), fractions, colors, cmLin));
g.setPaint(new LinearGradientPaint(new Point(-16384, 0), new Point(16384, 0), ratiosAr, colorsArr, cmLin));
g.fill(new Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat));
g.setTransform(oldAf);
g.setClip(null);
@@ -307,6 +343,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
GeneralPath ret = new GeneralPath();
int x = startX;
int y = startY;
boolean wasMoveTo = false;
for (SHAPERECORD rec : edges) {
int nx = rec.changeX(x);
int ny = rec.changeY(y);
@@ -316,12 +353,21 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
nx += startX;
ny += startY;
ret.moveTo(nx, ny);
wasMoveTo = true;
}
}
if (rec instanceof StraightEdgeRecord) {
if (!wasMoveTo) {
ret.moveTo(x, y);
wasMoveTo = true;
}
ret.lineTo(nx, ny);
}
if (rec instanceof CurvedEdgeRecord) {
if (!wasMoveTo) {
ret.moveTo(x, y);
wasMoveTo = true;
}
CurvedEdgeRecord cer = (CurvedEdgeRecord) rec;
ret.quadTo((x + cer.controlDeltaX), (y + cer.controlDeltaY), (x + cer.controlDeltaX + cer.anchorDeltaX), (y + cer.controlDeltaY + cer.anchorDeltaY));
}