From 34db7aa76bac071952c1c267e019c7d83da819c3 Mon Sep 17 00:00:00 2001 From: suhrke Date: Thu, 6 Jul 2017 18:00:27 -0700 Subject: [PATCH] Removed handling of alpha component in EC::hexToRgb --- ReflexToQ3/includes/EntityConverter.cpp | 20 +++++++------------- ReflexToQ3/includes/EntityConverter.hpp | 3 +-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ReflexToQ3/includes/EntityConverter.cpp b/ReflexToQ3/includes/EntityConverter.cpp index 66d9732..b4ed98e 100644 --- a/ReflexToQ3/includes/EntityConverter.cpp +++ b/ReflexToQ3/includes/EntityConverter.cpp @@ -638,9 +638,8 @@ EntityConverter::convertPointLight(const std::vector &lines) const float red; float green; float blue; - // Convert 32bit hex value into RGB values - float backgroundColor = 0.5; //!! Just a guess - hexToRGB(color, backgroundColor, red, green, blue); + // Convert 32bit hex RGBA value (ALPHA ALWAYS FULL) into RGB values + hexToRGB(color, red, green, blue); colorStream << "\"_color\" \"" << red << " " << green << " " << blue << "\"" << std::endl; convertedLines.push_back (colorStream.str() ); } @@ -741,7 +740,7 @@ EntityConverter::offset(const std::string &value, const float amount) const void -EntityConverter::hexToRGB(const std::string &hex, float background, float &r, float &g, float &b) const +EntityConverter::hexToRGB(const std::string &hex, float &r, float &g, float &b) const { unsigned int value; std::stringstream ss; @@ -749,16 +748,11 @@ EntityConverter::hexToRGB(const std::string &hex, float background, float &r, fl ss >> value; // BYTE ORDER IS ARGB + // Alpha value is always full -> can be ignored safely // Get each value and normalize - float sourceAlpha = ((value >> 24) & 0xFF) / 255.0; - float sourceRed = ((value >> 16) & 0xFF) / 255.0; - float sourceGreen = ((value >> 8) & 0xFF) / 255.0; - float sourceBlue = ((value) & 0xFF) / 255.0; - - // Convert RGB value close to something close to the source RGBA value - r = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceRed); - g = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceGreen); - b = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceBlue); + r = ((value >> 16) & 0xFF) / 255.0; + g = ((value >> 8) & 0xFF) / 255.0; + b = ((value) & 0xFF) / 255.0; } diff --git a/ReflexToQ3/includes/EntityConverter.hpp b/ReflexToQ3/includes/EntityConverter.hpp index 7128c38..ec368e2 100644 --- a/ReflexToQ3/includes/EntityConverter.hpp +++ b/ReflexToQ3/includes/EntityConverter.hpp @@ -200,13 +200,12 @@ class EntityConverter * Method: EntityConverter :: hexToRGB * Description: Convert 8 digit hex value into separate red, green, and blue values * Parameter: string hex, inputted hex RGBA value (leftmost byte is alpha, then RGB) - * Parameter: float background, background color * Parameter: float r, RETURN BY REFERENCE: converted red value * Parameter: float g, RETURN BY REFERENCE: converted green value * Parameter: float b, RETURN BY REFERENCE: converted blue value *-------------------------------------------------------------------------------------- */ - void hexToRGB(const std::string &hex, const float background, float &r, float &g, float &b) const; + void hexToRGB(const std::string &hex, float &r, float &g, float &b) const; /* *-------------------------------------------------------------------------------------- * Class: EntityConverter