From 2973ea654e488b89aaac2574d18bb00efc73b3d1 Mon Sep 17 00:00:00 2001 From: "Pete M. Wilson" Date: Thu, 7 Jan 2016 19:16:44 -0500 Subject: [PATCH] Fix Reduce Color Arithmetic Overflow --- GreenshotPlugin/Core/QuantizerHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GreenshotPlugin/Core/QuantizerHelper.cs b/GreenshotPlugin/Core/QuantizerHelper.cs index fbdb6a219..d9bfa1713 100644 --- a/GreenshotPlugin/Core/QuantizerHelper.cs +++ b/GreenshotPlugin/Core/QuantizerHelper.cs @@ -578,7 +578,7 @@ namespace GreenshotPlugin.Core { // the cube cannot be cut at bottom (this would lead to empty cube) if (halfWeight != 0) { - Single halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue; + Single halfDistance = (Single)halfRed * halfRed + (Single)halfGreen * halfGreen + (Single)halfBlue * halfBlue; Single temp = halfDistance / halfWeight; halfRed = wholeRed - halfRed; @@ -587,7 +587,7 @@ namespace GreenshotPlugin.Core { halfWeight = wholeWeight - halfWeight; if (halfWeight != 0) { - halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue; + halfDistance = (Single)halfRed * halfRed + (Single)halfGreen * halfGreen + (Single)halfBlue * halfBlue; temp += halfDistance / halfWeight; if (temp > result) {