From c4ac26b825f9c3af59328de9450b0453710f39c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 26 Sep 2014 20:51:12 +0200 Subject: [PATCH] color morphing fix --- .../decompiler/flash/types/MORPHGRADIENT.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java index 0d4e2c814..8cc96acf0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHGRADIENT.java @@ -12,11 +12,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; +import java.awt.Color; +import java.awt.color.ColorSpace; import java.io.Serializable; /** @@ -38,13 +41,13 @@ public class MORPHGRADIENT implements Serializable { @Internal public int numGradients; - public MORPHGRADRECORD[] gradientRecords; + public MORPHGRADRECORD[] gradientRecords; public static RGBA morphColor(RGBA c1, RGBA c2, int ratio) { - int r = (c1.red + (c2.red - c1.red) * ratio / 65535); - int g = (c1.green + (c2.green - c1.green) * ratio / 65535); - int b = (c1.blue + (c2.blue - c1.blue) * ratio / 65535); - int a = (c1.alpha + (c2.alpha - c1.alpha) * ratio / 65535); + int r = (int) (c1.red + (c2.red - c1.red) * ratio / 65535.0 + 0.5); + int g = (int) (c1.green + (c2.green - c1.green) * ratio / 65535.0 + 0.5); + int b = (int) (c1.blue + (c2.blue - c1.blue + 0.5) * ratio / 65535.0 + 0.5); + int a = (int) (c1.alpha + (c2.alpha - c1.alpha) * ratio / 65535.0f + 0.5); if (r > 255) { r = 255; }