- Fixed a bug when using Color.FromNonPremultiplied:
Replaced the weird buggy construct of code in Color.FromNonPremultiplied with a working (non complicated) version. Code readability ftw!
This commit is contained in:
parent
61f12a03fa
commit
dffb3bc29c
@ -811,23 +811,33 @@ namespace ANX.Framework
|
|||||||
{
|
{
|
||||||
Color color;
|
Color color;
|
||||||
|
|
||||||
r = r * a;
|
r = ClampValue((long)r * a / 255L);
|
||||||
g = g * a;
|
g = ClampValue((long)g * a / 255L);
|
||||||
b = b * a;
|
b = ClampValue((long)b * a / 255L);
|
||||||
|
|
||||||
|
/* //What the heck is this? Anyway it does not work!
|
||||||
if (((((r | g) | b) | a) & -256) != 0)
|
if (((((r | g) | b) | a) & -256) != 0)
|
||||||
{
|
{
|
||||||
r = r < 0 ? 0 : (r > 255 ? 255 : r);
|
r = r < 0 ? 0 : (r > 255 ? 255 : r);
|
||||||
g = g < 0 ? 0 : (g > 255 ? 255 : g);
|
g = g < 0 ? 0 : (g > 255 ? 255 : g);
|
||||||
b = b < 0 ? 0 : (b > 255 ? 255 : b);
|
b = b < 0 ? 0 : (b > 255 ? 255 : b);
|
||||||
a = a < 0 ? 0 : (a > 255 ? 255 : a);
|
a = a < 0 ? 0 : (a > 255 ? 255 : a);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
color.packedValue = (uint)(((r | g << 8) | b << 16) | a << 24);
|
color.packedValue = (uint)(((r | g << 8) | b << 16) | a << 24);
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int ClampValue(long value)
|
||||||
|
{
|
||||||
|
if (value < 0L)
|
||||||
|
return 0;
|
||||||
|
if (value > 255L)
|
||||||
|
return 255;
|
||||||
|
return (int) value;
|
||||||
|
}
|
||||||
|
|
||||||
public static Color FromNonPremultiplied(Vector4 vector)
|
public static Color FromNonPremultiplied(Vector4 vector)
|
||||||
{
|
{
|
||||||
Color color;
|
Color color;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user