Conversion and promotion fixes (#626)

This commit is contained in:
Michael Miller
2023-01-22 11:28:46 -08:00
committed by GitHub
parent 7d3a02919a
commit baf3b6b918
5 changed files with 13 additions and 13 deletions
+2 -2
View File
@@ -82,14 +82,14 @@ public:
Rgb48Color Correct(const Rgb48Color& original)
{
return RgbColor(T_METHOD::Correct(original.R),
return Rgb48Color(T_METHOD::Correct(original.R),
T_METHOD::Correct(original.G),
T_METHOD::Correct(original.B));
}
Rgbw64Color Correct(const Rgbw64Color& original)
{
return RgbwColor(T_METHOD::Correct(original.R),
return Rgbw64Color(T_METHOD::Correct(original.R),
T_METHOD::Correct(original.G),
T_METHOD::Correct(original.B),
T_METHOD::Correct(original.W));
+3 -3
View File
@@ -63,9 +63,9 @@ struct Rgb48Color : RgbColorBase
// ------------------------------------------------------------------------
Rgb48Color(const RgbColor& color)
{
R = (color.R == 0) ? 0 : (color.R << 8 | 0xff);
G = (color.G == 0) ? 0 : (color.G << 8 | 0xff);
B = (color.B == 0) ? 0 : (color.B << 8 | 0xff);
R = (uint16_t)color.R * 257; // 257 = MAXUINT16/MAXUINT8 = 65535/255
G = (uint16_t)color.R * 257;
B = (uint16_t)color.R * 257;
};
// ------------------------------------------------------------------------
+3 -3
View File
@@ -162,9 +162,9 @@ void RgbColor::Lighten(uint8_t delta)
RgbColor RgbColor::LinearBlend(const RgbColor& left, const RgbColor& right, float progress)
{
return RgbColor( left.R + ((right.R - left.R) * progress),
left.G + ((right.G - left.G) * progress),
left.B + ((right.B - left.B) * progress));
return RgbColor( left.R + (((int16_t)right.R - left.R) * progress),
left.G + (((int16_t)right.G - left.G) * progress),
left.B + (((int16_t)right.B - left.B) * progress));
}
RgbColor RgbColor::BilinearBlend(const RgbColor& c00,
+4 -4
View File
@@ -165,10 +165,10 @@ void RgbwColor::Lighten(uint8_t delta)
RgbwColor RgbwColor::LinearBlend(const RgbwColor& left, const RgbwColor& right, float progress)
{
return RgbwColor( left.R + ((right.R - left.R) * progress),
left.G + ((right.G - left.G) * progress),
left.B + ((right.B - left.B) * progress),
left.W + ((right.W - left.W) * progress) );
return RgbwColor( left.R + (((int16_t)right.R - left.R) * progress),
left.G + (((int16_t)right.G - left.G) * progress),
left.B + (((int16_t)right.B - left.B) * progress),
left.W + (((int16_t)right.W - left.W) * progress) );
}
RgbwColor RgbwColor::BilinearBlend(const RgbwColor& c00,
+1 -1
View File
@@ -159,7 +159,7 @@ SevenSegDigit SevenSegDigit::LinearBlend(const SevenSegDigit& left, const SevenS
for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++)
{
result.Segment[iSegment] = left.Segment[iSegment] + ((right.Segment[iSegment] - left.Segment[iSegment]) * progress);
result.Segment[iSegment] = left.Segment[iSegment] + (((int16_t)right.Segment[iSegment] - left.Segment[iSegment]) * progress);
}
return result;
}