Issue #164 DefineMorphShapeTag issues

This commit is contained in:
Jindra Petk
2013-07-05 16:12:18 +02:00
parent c9f0594620
commit 95fd7ef025
5 changed files with 92 additions and 7 deletions

View File

@@ -265,7 +265,7 @@ public class SWF {
* Construct SWF from stream
*
* @param is Stream to read SWF from
* @param listener
* @param listener
* @param paralelRead Use parallel threads?
* @throws IOException
*/
@@ -376,7 +376,7 @@ public class SWF {
*
* @param fis Input stream
* @param fos Output stream
* @return True on success
* @return True on success
*/
public static boolean fws2cws(InputStream fis, OutputStream fos) {
try {

View File

@@ -130,6 +130,7 @@ public class SWFInputStream extends InputStream {
*
* @param is Existing inputstream
* @param version Version of SWF to read
* @param startingPos
*/
public SWFInputStream(InputStream is, int version, long startingPos) {
this.version = version;
@@ -712,6 +713,13 @@ public class SWFInputStream extends InputStream {
* Reads list of actions from the stream. Reading ends with
* ActionEndFlag(=0) or end of the stream.
*
* @param listeners
* @param address
* @param ip
* @param rri
* @param version
* @param containerSWFOffset
* @param endip
* @return List of actions
* @throws IOException
*/
@@ -818,7 +826,7 @@ public class SWFInputStream extends InputStream {
if ((ip < ret.size()) && (!(ret.get(ip) instanceof ActionNop))) {
a = ret.get(ip);
if (a.getAddress() != ip) {
new Exception("Jump to the middle of the instruction ip " + ip + " ins " + a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), SWF.DEFAULT_VERSION, false)).printStackTrace();
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Jump to the middle of the instruction ip " + ip + " ins " + a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), SWF.DEFAULT_VERSION, false));
}
}
a.containerSWFOffset = containerSWFOffset;
@@ -1153,6 +1161,8 @@ public class SWFInputStream extends InputStream {
* Reads list of tags from the stream. Reading ends with End tag(=0) or end
* of the stream.
*
* @param level
* @param paralel
* @return List of tags
* @throws IOException
*/
@@ -1437,6 +1447,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one Tag from the stream
*
* @param level
* @param pos
* @param paralel
* @return Tag or null when End tag
* @throws IOException
*/
@@ -1448,6 +1461,10 @@ public class SWFInputStream extends InputStream {
* Reads one Tag from the stream with optional resolving (= reading tag
* content)
*
* @param level
* @param pos
* @param resolve
* @param paralel
* @return Tag or null when End tag
* @throws IOException
*/
@@ -1512,6 +1529,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one Action from the stream
*
* @param rri
* @return Action or null when ActionEndFlag or end of the stream
* @throws IOException
*/
@@ -2190,6 +2208,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one BUTTONRECORD value from the stream
*
* @param inDefineButton2 True when in DefineButton2
* @return BUTTONRECORD value
* @throws IOException
*/
@@ -2265,6 +2284,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one GRADRECORD value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return GRADRECORD value
* @throws IOException
*/
@@ -2282,6 +2302,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one GRADIENT value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return GRADIENT value
* @throws IOException
*/
@@ -2301,6 +2322,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one FOCALGRADIENT value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return FOCALGRADIENT value
* @throws IOException
*/
@@ -2320,6 +2342,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one FILLSTYLE value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return FILLSTYLE value
* @throws IOException
*/
@@ -2359,6 +2382,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one FILLSTYLEARRAY value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return FILLSTYLEARRAY value
* @throws IOException
*/
@@ -2379,6 +2403,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one LINESTYLE value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return LINESTYLE value
* @throws IOException
*/
@@ -2397,6 +2422,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one LINESTYLE2 value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return LINESTYLE2 value
* @throws IOException
*/
@@ -2426,6 +2452,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one LINESTYLEARRAY value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return LINESTYLEARRAY value
* @throws IOException
*/
@@ -2452,6 +2479,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one SHAPERECORD value from the stream
*
* @param fillBits
* @param lineBits
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return SHAPERECORD value
* @throws IOException
*/
@@ -2527,6 +2557,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one SHAPE value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return SHAPE value
* @throws IOException
*/
@@ -2541,6 +2572,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one SHAPEWITHSTYLE value from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @return SHAPEWITHSTYLE value
* @throws IOException
*/
@@ -2557,6 +2589,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads list of SHAPERECORDs from the stream
*
* @param shapeNum 1 in DefineShape, 2 in DefineShape2...
* @param fillBits
* @param lineBits
* @return SHAPERECORDs array
* @throws IOException
*/
@@ -2628,6 +2663,8 @@ public class SWFInputStream extends InputStream {
/**
* Reads one GLYPHENTRY value from the stream
*
* @param glyphBits
* @param advanceBits
* @return GLYPHENTRY value
* @throws IOException
*/
@@ -2641,6 +2678,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one TEXTRECORD value from the stream
*
* @param inDefineText2
* @param glyphBits
* @param advanceBits
* @return TEXTRECORD value
* @throws IOException
*/
@@ -2707,8 +2747,6 @@ public class SWFInputStream extends InputStream {
public MORPHGRADIENT readMORPHGRADIENT() throws IOException {
MORPHGRADIENT ret = new MORPHGRADIENT();
int numGradients = (int) readUI8();
ret.numGradientsExtra = numGradients & 0xf8; //some extra data. Are these the same as in GRADIENT or just obfuscator junk???
numGradients = numGradients & 0x7;
ret.gradientRecords = new MORPHGRADRECORD[numGradients];
for (int i = 0; i < numGradients; i++) {
ret.gradientRecords[i] = readMORPHGRADRECORD();
@@ -2819,6 +2857,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one MORPHLINESTYLEARRAY value from the stream
*
* @param morphShapeNum 1 on DefineMorphShape, 2 on DefineMorphShape2
* @return MORPHLINESTYLEARRAY value
* @throws IOException
*/
@@ -2845,6 +2884,7 @@ public class SWFInputStream extends InputStream {
/**
* Reads one KERNINGRECORD value from the stream
*
* @param fontFlagsWideCodes
* @return KERNINGRECORD value
* @throws IOException
*/
@@ -2938,6 +2978,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one COLORMAPDATA value from the stream
*
* @param colorTableSize
* @param bitmapWidth
* @param bitmapHeight
* @return COLORMAPDATA value
* @throws IOException
*/
@@ -2965,6 +3008,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one BITMAPDATA value from the stream
*
* @param bitmapFormat
* @param bitmapWidth
* @param bitmapHeight
* @return COLORMAPDATA value
* @throws IOException
*/
@@ -3001,6 +3047,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one BITMAPDATA value from the stream
*
* @param bitmapFormat
* @param bitmapWidth
* @param bitmapHeight
* @return COLORMAPDATA value
* @throws IOException
*/
@@ -3018,6 +3067,9 @@ public class SWFInputStream extends InputStream {
/**
* Reads one ALPHACOLORMAPDATA value from the stream
*
* @param colorTableSize
* @param bitmapWidth
* @param bitmapHeight
* @return ALPHACOLORMAPDATA value
* @throws IOException
*/

View File

@@ -997,6 +997,7 @@ public class SWFOutputStream extends OutputStream {
* Writes FILLSTYLE value to the stream
*
* @param value FILLSTYLE value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeFILLSTYLE(FILLSTYLE value, int shapeNum) throws IOException {
@@ -1034,6 +1035,7 @@ public class SWFOutputStream extends OutputStream {
* Writes FILLSTYLEARRAY value to the stream
*
* @param value FILLSTYLEARRAY value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeFILLSTYLEARRAY(FILLSTYLEARRAY value, int shapeNum) throws IOException {
@@ -1057,6 +1059,7 @@ public class SWFOutputStream extends OutputStream {
* Writes FOCALGRADIENT value to the stream
*
* @param value FILLSTYLEARRAY value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeFOCALGRADIENT(FOCALGRADIENT value, int shapeNum) throws IOException {
@@ -1073,6 +1076,7 @@ public class SWFOutputStream extends OutputStream {
* Writes GRADIENT value to the stream
*
* @param value GRADIENT value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeGRADIENT(GRADIENT value, int shapeNum) throws IOException {
@@ -1088,6 +1092,7 @@ public class SWFOutputStream extends OutputStream {
* Writes GRADRECORD value to the stream
*
* @param value GRADRECORD value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeGRADRECORD(GRADRECORD value, int shapeNum) throws IOException {
@@ -1103,6 +1108,7 @@ public class SWFOutputStream extends OutputStream {
* Writes LINESTYLE value to the stream
*
* @param value LINESTYLE value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeLINESTYLE(LINESTYLE value, int shapeNum) throws IOException {
@@ -1118,6 +1124,7 @@ public class SWFOutputStream extends OutputStream {
* Writes LINESTYLE2 value to the stream
*
* @param value LINESTYLE2 value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeLINESTYLE2(LINESTYLE2 value, int shapeNum) throws IOException {
@@ -1145,6 +1152,7 @@ public class SWFOutputStream extends OutputStream {
* Writes LINESTYLEARRAY value to the stream
*
* @param value FILLSTYLEARRAY value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeLINESTYLEARRAY(LINESTYLEARRAY value, int shapeNum) throws IOException {
@@ -1178,6 +1186,7 @@ public class SWFOutputStream extends OutputStream {
* Writes SHAPE value to the stream
*
* @param value SHAPE value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeSHAPE(SHAPE value, int shapeNum) throws IOException {
@@ -1190,6 +1199,7 @@ public class SWFOutputStream extends OutputStream {
* Writes SHAPEWITHSTYLE value to the stream
*
* @param value SHAPEWITHSTYLE value
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeSHAPEWITHSTYLE(SHAPEWITHSTYLE value, int shapeNum) throws IOException {
@@ -1204,6 +1214,9 @@ public class SWFOutputStream extends OutputStream {
* Writes SHAPERECORDs value to the stream
*
* @param value SHAPERECORDS value
* @param fillBits
* @param lineBits
* @param shapeNum 1 in DefineShape, 2 in DefineShape2,...
* @throws IOException
*/
public void writeSHAPERECORDS(List<SHAPERECORD> value, int fillBits, int lineBits, int shapeNum) throws IOException {
@@ -1316,6 +1329,9 @@ public class SWFOutputStream extends OutputStream {
* Writes TEXTRECORD value to the stream
*
* @param value TEXTRECORD value
* @param inDefineText2
* @param glyphBits
* @param advanceBits
* @throws IOException
*/
public void writeTEXTRECORD(TEXTRECORD value, boolean inDefineText2, int glyphBits, int advanceBits) throws IOException {
@@ -1355,6 +1371,8 @@ public class SWFOutputStream extends OutputStream {
* Writes GLYPHENTRY value to the stream
*
* @param value GLYPHENTRY value
* @param glyphBits
* @param advanceBits
* @throws IOException
*/
public void writeGLYPHENTRY(GLYPHENTRY value, int glyphBits, int advanceBits) throws IOException {
@@ -1366,6 +1384,7 @@ public class SWFOutputStream extends OutputStream {
* Writes MORPHFILLSTYLE value to the stream
*
* @param value MORPHFILLSTYLE value
* @param shapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
* @throws IOException
*/
public void writeMORPHFILLSTYLE(MORPHFILLSTYLE value, int shapeNum) throws IOException {
@@ -1398,6 +1417,7 @@ public class SWFOutputStream extends OutputStream {
* WritesMORPH FILLSTYLEARRAY value to the stream
*
* @param value MORPHFILLSTYLEARRAY value
* @param morphShapeNum 1 on DefineMorphShape, 2 on DefineMorphShape
* @throws IOException
*/
public void writeMORPHFILLSTYLEARRAY(MORPHFILLSTYLEARRAY value, int morphShapeNum) throws IOException {
@@ -1417,10 +1437,11 @@ public class SWFOutputStream extends OutputStream {
* Writes MORPHGRADIENT value to the stream
*
* @param value MORPHGRADIENT value
* @param shapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
* @throws IOException
*/
public void writeMORPHGRADIENT(MORPHGRADIENT value, int shapeNum) throws IOException {
writeUI8(value.gradientRecords.length + value.numGradientsExtra);
writeUI8(value.gradientRecords.length);
for (int i = 0; i < value.gradientRecords.length; i++) {
writeMORPHGRADRECORD(value.gradientRecords[i]);
}
@@ -1443,6 +1464,7 @@ public class SWFOutputStream extends OutputStream {
* Writes MORPHLINESTYLE value to the stream
*
* @param value LINESTYLE value
* @param shapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
* @throws IOException
*/
public void writeMORPHLINESTYLE(MORPHLINESTYLE value, int shapeNum) throws IOException {
@@ -1457,6 +1479,7 @@ public class SWFOutputStream extends OutputStream {
* Writes MORPHLINESTYLE2 value to the stream
*
* @param value MORPHLINESTYLE2 value
* @param shapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
* @throws IOException
*/
public void writeMORPHLINESTYLE2(MORPHLINESTYLE2 value, int shapeNum) throws IOException {
@@ -1486,6 +1509,7 @@ public class SWFOutputStream extends OutputStream {
* Writes MORPHLINESTYLEARRAY value to the stream
*
* @param value MORPHFILLSTYLEARRAY value
* @param morphShapeNum 1 in DefineMorphShape, 2 in DefineMorphShape2,...
* @throws IOException
*/
public void writeMORPHLINESTYLEARRAY(MORPHLINESTYLEARRAY value, int morphShapeNum) throws IOException {
@@ -1519,6 +1543,7 @@ public class SWFOutputStream extends OutputStream {
* Writes KERNINGRECORD value to the stream
*
* @param value KERNINGRECORD value
* @param fontFlagsWideCodes
* @throws IOException
*/
public void writeKERNINGRECORD(KERNINGRECORD value, boolean fontFlagsWideCodes) throws IOException {
@@ -1578,6 +1603,10 @@ public class SWFOutputStream extends OutputStream {
/**
* Reads one BITMAPDATA value from the stream
*
* @param value
* @param bitmapFormat
* @param bitmapWidth
* @param bitmapHeight
* @throws IOException
*/
public void writeBITMAPDATA(BITMAPDATA value, int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException {
@@ -1606,6 +1635,10 @@ public class SWFOutputStream extends OutputStream {
/**
* Reads one ALPHABITMAPDATA value from the stream
*
* @param value
* @param bitmapFormat
* @param bitmapWidth
* @param bitmapHeight
* @throws IOException
*/
public void writeALPHABITMAPDATA(ALPHABITMAPDATA value, int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException {

View File

@@ -110,6 +110,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
*
* @param data Data bytes
* @param version SWF version
* @param pos
* @throws IOException
*/
public DefineMorphShapeTag(byte data[], int version, long pos) throws IOException {

View File

@@ -24,7 +24,6 @@ public class MORPHGRADIENT {
public int numGradients;
public MORPHGRADRECORD gradientRecords[];
public int numGradientsExtra;
public static RGBA morphColor(RGBA c1, RGBA c2, int ratio) {
int r = (c1.red + (c2.red - c1.red) * ratio / 65535);