Fixed: #2561 Cannot set filter strength to 128 or above

This commit is contained in:
Jindra Petřík
2025-11-16 10:40:46 +01:00
parent 0aa76cefb9
commit 8dc3efc528
18 changed files with 113 additions and 35 deletions

View File

@@ -152,6 +152,7 @@ import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.treeitems.Openable;
import com.jpexs.decompiler.flash.treeitems.OpenableList;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RECT;
@@ -159,6 +160,7 @@ import com.jpexs.decompiler.flash.types.SHAPE;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFField;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.sound.SoundInfoSoundCacheEntry;
import com.jpexs.decompiler.flash.xfl.FLAVersion;
import com.jpexs.decompiler.flash.xfl.XFLConverter;
@@ -267,16 +269,19 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
/**
* Movie frame rate.
*/
@SWFType(BasicType.UFIXED8)
public float frameRate;
/**
* Number of frames in movie.
*/
@SWFType(BasicType.UI16)
public int frameCount;
/**
* Version of SWF.
*/
@SWFType(BasicType.UI8)
public int version;
/**
@@ -1906,7 +1911,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
sos.writeUI8(version);
sos.writeUI32(0); // placeholder for file length
sos.writeRECT(displayRect);
sos.writeFIXED8(frameRate);
sos.writeUFIXED8(frameRate);
sos.writeUI16(frameCount);
sos.writeTags(getTags());
@@ -2276,7 +2281,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
}
sis.setPercentMax(fileSize);
displayRect = sis.readRECT("displayRect");
frameRate = sis.readFIXED8("frameRate");
frameRate = sis.readUFIXED8("frameRate");
frameCount = sis.readUI16("frameCount");
List<Tag> tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, lazy);
if (tags.size() > 0 && tags.get(tags.size() - 1).getId() == EndTag.ID) {

View File

@@ -847,6 +847,21 @@ public class SWFInputStream implements AutoCloseable {
endDumpLevel(ret);
return ret;
}
/**
* Reads one UFIXED8 (Fixed point 8.8) unsigned value from the stream.
*
* @param name Name
* @return UFIXED8 value
* @throws IOException On I/O error
*/
public float readUFIXED8(String name) throws IOException {
newDumpLevel(name, "UFIXED8");
int si = readUI16Internal();
float ret = si / (float) (1 << 8);
endDumpLevel(ret);
return ret;
}
/**
* Reads long value from the stream.
@@ -2547,7 +2562,7 @@ public class SWFInputStream implements AutoCloseable {
ret.blurY = readFIXED("blurY");
ret.angle = readFIXED("angle");
ret.distance = readFIXED("distance");
ret.strength = readFIXED8("strength");
ret.strength = readUFIXED8("strength");
ret.innerShadow = readUB(1, "innerShadow") == 1;
ret.knockout = readUB(1, "knockout") == 1;
ret.compositeSource = readUB(1, "compositeSource") == 1;
@@ -2569,7 +2584,7 @@ public class SWFInputStream implements AutoCloseable {
ret.glowColor = readRGBA("glowColor");
ret.blurX = readFIXED("blurX");
ret.blurY = readFIXED("blurY");
ret.strength = readFIXED8("strength");
ret.strength = readUFIXED8("strength");
ret.innerGlow = readUB(1, "innerGlow") == 1;
ret.knockout = readUB(1, "knockout") == 1;
ret.compositeSource = readUB(1, "compositeSource") == 1;
@@ -2594,7 +2609,7 @@ public class SWFInputStream implements AutoCloseable {
ret.blurY = readFIXED("blurY");
ret.angle = readFIXED("angle");
ret.distance = readFIXED("distance");
ret.strength = readFIXED8("strength");
ret.strength = readUFIXED8("strength");
ret.innerShadow = readUB(1, "innerShadow") == 1;
ret.knockout = readUB(1, "knockout") == 1;
ret.compositeSource = readUB(1, "compositeSource") == 1;
@@ -2627,7 +2642,7 @@ public class SWFInputStream implements AutoCloseable {
ret.blurY = readFIXED("blurY");
ret.angle = readFIXED("angle");
ret.distance = readFIXED("distance");
ret.strength = readFIXED8("strength");
ret.strength = readUFIXED8("strength");
ret.innerShadow = readUB(1, "innerShadow") == 1;
ret.knockout = readUB(1, "knockout") == 1;
ret.compositeSource = readUB(1, "compositeSource") == 1;
@@ -2660,7 +2675,7 @@ public class SWFInputStream implements AutoCloseable {
ret.blurY = readFIXED("blurY");
ret.angle = readFIXED("angle");
ret.distance = readFIXED("distance");
ret.strength = readFIXED8("strength");
ret.strength = readUFIXED8("strength");
ret.innerShadow = readUB(1, "innerShadow") == 1;
ret.knockout = readUB(1, "knockout") == 1;
ret.compositeSource = readUB(1, "compositeSource") == 1;
@@ -3009,7 +3024,7 @@ public class SWFInputStream implements AutoCloseable {
ret.noClose = (int) readUB(1, "noClose") == 1;
ret.endCapStyle = (int) readUB(2, "endCapStyle");
if (ret.joinStyle == LINESTYLE2.MITER_JOIN) {
ret.miterLimitFactor = readFIXED8("miterLimitFactor");
ret.miterLimitFactor = readUFIXED8("miterLimitFactor");
}
if (!ret.hasFillFlag) {
ret.color = readRGBA("color");
@@ -3499,7 +3514,7 @@ public class SWFInputStream implements AutoCloseable {
ret.noClose = (int) readUB(1, "noClose") == 1;
ret.endCapStyle = (int) readUB(2, "endCapStyle");
if (ret.joinStyle == LINESTYLE2.MITER_JOIN) {
ret.miterLimitFactor = readFIXED8("miterLimitFactor");
ret.miterLimitFactor = readUFIXED8("miterLimitFactor");
}
if (!ret.hasFillFlag) {
ret.startColor = readRGBA("startColor");

View File

@@ -342,7 +342,7 @@ public class SWFOutputStream extends OutputStream {
}
/**
* Writes FIXED (Fixed point 16.16) value to the stream.
* Writes FIXED (Fixed point 16.16) igned value to the stream.
*
* @param value FIXED value
* @throws IOException On I/O error
@@ -353,7 +353,7 @@ public class SWFOutputStream extends OutputStream {
}
/**
* Writes FIXED8 (Fixed point 8.8) value to the stream.
* Writes FIXED8 (Fixed point 8.8) signed value to the stream.
*
* @param value FIXED8 value
* @throws IOException On I/O error
@@ -362,6 +362,17 @@ public class SWFOutputStream extends OutputStream {
int valueInt = (int) (value * (1 << 8));
writeSI16(valueInt);
}
/**
* Writes UFIXED8 (Fixed point 8.8) unsigned value to the stream.
*
* @param value FIXED8 value
* @throws IOException On I/O error
*/
public void writeUFIXED8(float value) throws IOException {
int valueInt = (int) (value * (1 << 8));
writeUI16(valueInt);
}
/**
* Writes long value to the stream.
@@ -1074,7 +1085,7 @@ public class SWFOutputStream extends OutputStream {
writeFIXED(value.blurY);
writeFIXED(value.angle);
writeFIXED(value.distance);
writeFIXED8(value.strength);
writeUFIXED8(value.strength);
writeUB(1, value.innerShadow ? 1 : 0);
writeUB(1, value.knockout ? 1 : 0);
writeUB(1, value.compositeSource ? 1 : 0);
@@ -1091,7 +1102,7 @@ public class SWFOutputStream extends OutputStream {
writeRGBA(value.glowColor);
writeFIXED(value.blurX);
writeFIXED(value.blurY);
writeFIXED8(value.strength);
writeUFIXED8(value.strength);
writeUB(1, value.innerGlow ? 1 : 0);
writeUB(1, value.knockout ? 1 : 0);
writeUB(1, value.compositeSource ? 1 : 0);
@@ -1111,7 +1122,7 @@ public class SWFOutputStream extends OutputStream {
writeFIXED(value.blurY);
writeFIXED(value.angle);
writeFIXED(value.distance);
writeFIXED8(value.strength);
writeUFIXED8(value.strength);
writeUB(1, value.innerShadow ? 1 : 0);
writeUB(1, value.knockout ? 1 : 0);
writeUB(1, value.compositeSource ? 1 : 0);
@@ -1137,7 +1148,7 @@ public class SWFOutputStream extends OutputStream {
writeFIXED(value.blurY);
writeFIXED(value.angle);
writeFIXED(value.distance);
writeFIXED8(value.strength);
writeUFIXED8(value.strength);
writeUB(1, value.innerShadow ? 1 : 0);
writeUB(1, value.knockout ? 1 : 0);
writeUB(1, value.compositeSource ? 1 : 0);
@@ -1163,7 +1174,7 @@ public class SWFOutputStream extends OutputStream {
writeFIXED(value.blurY);
writeFIXED(value.angle);
writeFIXED(value.distance);
writeFIXED8(value.strength);
writeUFIXED8(value.strength);
writeUB(1, value.innerShadow ? 1 : 0);
writeUB(1, value.knockout ? 1 : 0);
writeUB(1, value.compositeSource ? 1 : 0);
@@ -1449,7 +1460,7 @@ public class SWFOutputStream extends OutputStream {
writeUB(1, value.noClose ? 1 : 0);
writeUB(2, value.endCapStyle);
if (value.joinStyle == LINESTYLE2.MITER_JOIN) {
writeFIXED8(value.miterLimitFactor);
writeUFIXED8(value.miterLimitFactor);
}
if (!value.hasFillFlag) {
writeRGBA((RGBA) value.color);
@@ -1899,7 +1910,7 @@ public class SWFOutputStream extends OutputStream {
writeUB(1, value.noClose ? 1 : 0);
writeUB(2, value.endCapStyle);
if (value.joinStyle == LINESTYLE2.MITER_JOIN) {
writeFIXED8(value.miterLimitFactor);
writeUFIXED8(value.miterLimitFactor);
}
if (!value.hasFillFlag) {
writeRGBA(value.startColor);

View File

@@ -340,7 +340,7 @@ public class PreviewExporter {
int height = outrect.getHeight();
sos2.writeRECT(outrect);
sos2.writeFIXED8(frameRate);
sos2.writeUFIXED8(frameRate);
sos2.writeUI16(frameCount); //framecnt
FileAttributesTag fa = swf.getFileAttributes();

View File

@@ -672,7 +672,7 @@ public class AS3ScriptExporter {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos, swf.version, swf.getCharset());
sos2.writeRECT(swf.displayRect);
sos2.writeFIXED8(swf.frameRate);
sos2.writeUFIXED8(swf.frameRate);
sos2.writeUI16(1);
FileAttributesTag fa = swf.getFileAttributes();
if (fa != null) {

View File

@@ -64,21 +64,25 @@ public enum BasicType {
*/
FB,
/**
* Single-precision (32-bit) floating-point number
* Signed Single-precision (32-bit) floating-point number
*/
FLOAT,
/**
* Half-precision (16-bit) floating-point number
* Signed Half-precision (16-bit) floating-point number
*/
FLOAT16,
/**
* 32-bit 16.16 fixed-point number
* Signed 32-bit 16.16 fixed-point number
*/
FIXED,
/**
* 16-bit 8.8 fixed-point number
* Signed 16-bit 8.8 fixed-point number
*/
FIXED8,
/**
* Unsigned 16-bit 8.8 fixed-point number
*/
UFIXED8,
/**
* None
*/

View File

@@ -132,7 +132,7 @@ public class LINESTYLE2 implements NeedsCharacters, Serializable, ILINESTYLE {
/**
* Miter limit factor
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
@Conditional(value = "joinStyle", options = {MITER_JOIN})
public float miterLimitFactor;

View File

@@ -133,7 +133,7 @@ public class MORPHLINESTYLE2 implements Serializable {
/**
* Miter limit factor
*/
@SWFType(value = BasicType.FIXED8)
@SWFType(value = BasicType.UFIXED8)
@Conditional(value = "joinStyle", options = {MITER_JOIN})
public float miterLimitFactor;

View File

@@ -70,7 +70,7 @@ public class BEVELFILTER extends FILTER {
/**
* Strength of the drop shadow
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
public float strength = 1f;
/**

View File

@@ -65,7 +65,7 @@ public class DROPSHADOWFILTER extends FILTER {
/**
* Strength of the drop shadow
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
public float strength = 1f;
/**

View File

@@ -53,7 +53,7 @@ public class GLOWFILTER extends FILTER {
/**
* Strength of the glow
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
public float strength = 1;
/**

View File

@@ -80,7 +80,7 @@ public class GRADIENTBEVELFILTER extends FILTER {
/**
* Strength of the gradient bevel
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
public float strength = 1;
/**

View File

@@ -79,7 +79,7 @@ public class GRADIENTGLOWFILTER extends FILTER {
/**
* Strength of the gradient glow
*/
@SWFType(BasicType.FIXED8)
@SWFType(BasicType.UFIXED8)
public float strength = 1;
/**