diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c56e5b65..c40fdaffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file. exception. Also truncated video length. - [#2550] FLV video import - incorrect frame position caused by wrong FLV tag sort - Mac package problems related to BOM file (updated jbomutils library) +- [#2561] Cannot set filter strength to 128 or above ## [24.1.0] - 2025-09-28 ### Added @@ -4041,6 +4042,7 @@ Major version of SWF to XML export changed to 2. [#2552]: https://www.free-decompiler.com/flash/issues/2552 [#2551]: https://www.free-decompiler.com/flash/issues/2551 [#2550]: https://www.free-decompiler.com/flash/issues/2550 +[#2561]: https://www.free-decompiler.com/flash/issues/2561 [#2477]: https://www.free-decompiler.com/flash/issues/2477 [#2478]: https://www.free-decompiler.com/flash/issues/2478 [#2485]: https://www.free-decompiler.com/flash/issues/2485 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 0fd8657d9..3b5669fe2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -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 tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, lazy); if (tags.size() > 0 && tags.get(tags.size() - 1).getId() == EndTag.ID) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index aad726df3..be737f583 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -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"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 3c0fc8fcc..e4c19623b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -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); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java index 136ac2422..a58b84dea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java @@ -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(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index a57bbe48f..b330370d9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -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) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BasicType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BasicType.java index 44f01300a..baf6f9fa2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BasicType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BasicType.java @@ -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 */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java index cce7d50af..a69f53d00 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java @@ -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; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLE2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLE2.java index 4f25d57e4..500958a74 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLE2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLE2.java @@ -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; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java index 4509eac32..d6ebcb08b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java @@ -70,7 +70,7 @@ public class BEVELFILTER extends FILTER { /** * Strength of the drop shadow */ - @SWFType(BasicType.FIXED8) + @SWFType(BasicType.UFIXED8) public float strength = 1f; /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java index c41fed661..1c6d00419 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java @@ -65,7 +65,7 @@ public class DROPSHADOWFILTER extends FILTER { /** * Strength of the drop shadow */ - @SWFType(BasicType.FIXED8) + @SWFType(BasicType.UFIXED8) public float strength = 1f; /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java index f4892ecba..64c40b804 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java @@ -53,7 +53,7 @@ public class GLOWFILTER extends FILTER { /** * Strength of the glow */ - @SWFType(BasicType.FIXED8) + @SWFType(BasicType.UFIXED8) public float strength = 1; /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java index fc9888ef9..a04e56cb1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java @@ -80,7 +80,7 @@ public class GRADIENTBEVELFILTER extends FILTER { /** * Strength of the gradient bevel */ - @SWFType(BasicType.FIXED8) + @SWFType(BasicType.UFIXED8) public float strength = 1; /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java index 5f2abde3c..9bf0bfbcb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java @@ -79,7 +79,7 @@ public class GRADIENTGLOWFILTER extends FILTER { /** * Strength of the gradient glow */ - @SWFType(BasicType.FIXED8) + @SWFType(BasicType.UFIXED8) public float strength = 1; /** diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/SWFStreamTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/SWFStreamTest.java index a722da9aa..983183908 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/SWFStreamTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/SWFStreamTest.java @@ -161,6 +161,18 @@ public class SWFStreamTest { assertEquals(ff, ff2, "Written and read value not equals. Written: " + ff + " read: " + ff2); sis.close(); } + + float[] uffs = new float[]{200.25f, 0.25f, 255.75f, 50.25f}; + for (float ff : uffs) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, SWF.DEFAULT_VERSION, Utf8Helper.charsetName); + sos.writeUFIXED8(ff); + sos.close(); + sis = new SWFInputStream(null, baos.toByteArray()); + float ff2 = sis.readUFIXED8("test"); + assertEquals(ff, ff2, "Written and read value not equals. Written: " + ff + " read: " + ff2); + sis.close(); + } } @Test diff --git a/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java b/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java index d949c9633..5134fe216 100644 --- a/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java +++ b/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java @@ -561,7 +561,7 @@ public class FiltersTreeTable extends JTreeTable { } }); } else if (realValue.getClass() == Double.class || realValue.getClass() == Float.class) { - editor = new FloatEditor(filterField.toString(), filterField.filter, filterField.field, -1, realValue.getClass()); + editor = new FloatEditor(filterField.toString(), filterField.filter, filterField.field, -1, realValue.getClass(), filterField.field.getAnnotation(SWFType.class)); if ("angle".equals(filterField.field.getName())) { ((FloatEditor) editor).setValueNormalizer(new ValueNormalizer() { @Override diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 72bf125b3..0e8942be8 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -353,7 +353,7 @@ public class GenericTagTreePanel extends GenericTagPanel { editor = new EnumEditor(field.getName(), obj, field, index, type, swfType, values); } else if (type.equals(double.class) || type.equals(Double.class) || type.equals(float.class) || type.equals(Float.class)) { - editor = new FloatEditor(field.getName(), obj, field, index, type); + editor = new FloatEditor(field.getName(), obj, field, index, type, swfType); } else if (type.equals(int.class) || type.equals(Integer.class) || type.equals(short.class) || type.equals(Short.class) || type.equals(long.class) || type.equals(Long.class)) { diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/FloatEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/FloatEditor.java index 49543efd4..994517db4 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/FloatEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/FloatEditor.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui.generictageditors; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.Helper; import com.jpexs.helpers.ReflectionTools; import java.awt.Component; @@ -61,6 +62,7 @@ public class FloatEditor extends JPanel implements GenericTagEditor { private JTextField textField; private JLabel linkLabel; + private SWFType swfType; @Override public Dimension getPreferredSize() { @@ -79,7 +81,7 @@ public class FloatEditor extends JPanel implements GenericTagEditor { return 0; } - public FloatEditor(String fieldName, Object obj, Field field, int index, Class type) { + public FloatEditor(String fieldName, Object obj, Field field, int index, Class type, SWFType swfType) { this.obj = obj; this.field = field; this.index = index; @@ -127,6 +129,7 @@ public class FloatEditor extends JPanel implements GenericTagEditor { linkLabel.setVisible(false); reset(); + this.swfType = swfType; } @Override @@ -159,10 +162,36 @@ public class FloatEditor extends JPanel implements GenericTagEditor { val = Double.valueOf(textField.getText()); } else { val = Float.valueOf(textField.getText()); - } + } if (normalizer != null) { val = normalizer.toFieldValue(val); } + + if (swfType != null) { + switch (swfType.value()) { + case UFIXED8: + if ((float) val > 255f) { + val = 255f; + } else if ((float) val < 0) { + val = 0f; + } + break; + case FIXED8: + if ((float) val > 127f) { + val = 127f; + } else if ((float) val < -128f) { + val = -128f; + } + break; + case FIXED: + if ((double) val > 32767.0) { + val = 32767.0; + } else if ((double) val < -32768.0) { + val = -32768.0; + } + break; + } + } ReflectionTools.setValue(obj, field, index, val);