Просмотр исходного кода

Fixed reversed RGBA values when converting Color from uint

Ivan Safrin 14 лет назад
Родитель
Сommit
89a1b60036
2 измененных файлов с 9 добавлено и 5 удалено
  1. 5 1
      Core/Contents/Include/PolyColor.h
  2. 4 4
      Core/Contents/Source/PolyColor.cpp

+ 5 - 1
Core/Contents/Include/PolyColor.h

@@ -81,7 +81,11 @@ namespace Polycode {
 				Number nb = b * v2.b;
 				Number na = a * v2.a;				
 				return Color(nr, ng, nb, na);
-			}			
+			}	
+			
+			bool operator == (const Color& c2) {
+				return (((int)255.0*r) == ((int)255.0*c2.r) && ((int)255.0*g) == ((int)255.0*c2.g) && ((int)255.0*b) == ((int)255.0*c2.b) && ((int)255.0*a) == ((int)255.0*c2.a));
+			}
 			
 			/** 
 			* Sets the color using an integer color value

+ 4 - 4
Core/Contents/Source/PolyColor.cpp

@@ -59,10 +59,10 @@ void Color::setColorHexRGB(unsigned int hex) {
 }
 
 void Color::setColorHex(unsigned int hex) {
-	int tr = (hex >> 24) & 0xFF;
-	int tg = (hex >> 16) & 0xFF;
-	int tb = (hex >> 8) & 0xFF;
-	int ta = (hex ) & 0xFF;
+	int ta = (hex >> 24) & 0xFF;
+	int tb = (hex >> 16) & 0xFF;
+	int tg = (hex >> 8) & 0xFF;
+	int tr = (hex ) & 0xFF;
 	
 	r = ((Number)tr)/255.0f;
 	g = ((Number)tg)/255.0f;