From c43e4afd57be3040a108aa30b776ffc33c72a31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Thu, 5 Sep 2013 19:22:05 +0200 Subject: [PATCH] final MORPHGRADIENT fix --- trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java | 8 +++++--- .../src/com/jpexs/decompiler/flash/SWFOutputStream.java | 6 +++++- trunk/src/com/jpexs/decompiler/flash/types/GRADIENT.java | 6 ++++++ .../com/jpexs/decompiler/flash/types/MORPHGRADIENT.java | 9 ++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index f2adb51a9..9d4d91c17 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -2288,9 +2288,11 @@ public class SWFInputStream extends InputStream { */ public MORPHGRADIENT readMORPHGRADIENT() throws IOException { MORPHGRADIENT ret = new MORPHGRADIENT(); - int numGradients = (int) readUI8(); - ret.numGradientsExtra = numGradients & 0xf0; //some extra data. Are these the same as in GRADIENT or just obfuscator junk??? - numGradients = numGradients & 0x0f; + //Despite of documentation (UI8 1-8), there are two fields + // spreadMode and interPolationMode which are same as in GRADIENT + ret.spreadMode = (int) readUB(2); + ret.interPolationMode = (int) readUB(2); + int numGradients = (int) readUB(4); ret.gradientRecords = new MORPHGRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { ret.gradientRecords[i] = readMORPHGRADRECORD(); diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 7bd982568..c262ccbd9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -1471,7 +1471,11 @@ public class SWFOutputStream extends OutputStream { * @throws IOException */ public void writeMORPHGRADIENT(MORPHGRADIENT value, int shapeNum) throws IOException { - writeUI8(value.gradientRecords.length + value.numGradientsExtra); + //Despite of documentation (UI8 1-8), there are two fields + // spreadMode and interPolationMode which are same as in GRADIENT + writeUB(2, value.spreadMode); + writeUB(2, value.interPolationMode); + writeUB(4, value.gradientRecords.length); for (int i = 0; i < value.gradientRecords.length; i++) { writeMORPHGRADRECORD(value.gradientRecords[i]); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/GRADIENT.java b/trunk/src/com/jpexs/decompiler/flash/types/GRADIENT.java index db87fa22f..9ffd65db1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/GRADIENT.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/GRADIENT.java @@ -22,11 +22,17 @@ package com.jpexs.decompiler.flash.types; */ public class GRADIENT { + /** + * Spread mode + */ public int spreadMode; public static final int SPREAD_PAD_MODE = 0; public static final int SPREAD_REFLECT_MODE = 1; public static final int SPREAD_REPEAT_MODE = 2; public static final int SPREAD_RESERVED = 3; + /** + * Interpolation mode + */ public int interPolationMode; public static final int INTERPOLATION_RGB_MODE = 0; public static final int INTERPOLATION_LINEAR_RGB_MODE = 1; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java b/trunk/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java index b01af9eb0..62ba625cb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java @@ -22,9 +22,16 @@ package com.jpexs.decompiler.flash.types; */ public class MORPHGRADIENT { + /** + * Spread mode. See GRADIENT.SPREAD_* constants + */ + public int spreadMode; + /** + * Interpolation mode. See GRADIENT.INTERPOLATION_* constants + */ + public int interPolationMode; 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);