mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Add some initial widget functionality (prefs partly working)
This commit is contained in:
28
PortabilityLayer/PLCTabReducer.cpp
Normal file
28
PortabilityLayer/PLCTabReducer.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "PLCTabReducer.h"
|
||||
#include "RGBAColor.h"
|
||||
|
||||
#include "SharedTypes.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
uint8_t CTabReducer::DecodeClutItemChannel(const uint8_t *color16)
|
||||
{
|
||||
const int colorHigh = color16[0];
|
||||
const int colorLow = color16[1];
|
||||
|
||||
const int lowDelta = colorLow - colorHigh;
|
||||
if (lowDelta < -128)
|
||||
return static_cast<uint8_t>(colorHigh - 1);
|
||||
else if (lowDelta > 128)
|
||||
return static_cast<uint8_t>(colorHigh + 1);
|
||||
return static_cast<uint8_t>(colorHigh);
|
||||
}
|
||||
|
||||
RGBAColor CTabReducer::DecodeClutItem(const BEColorTableItem &clutItem)
|
||||
{
|
||||
const uint8_t r = DecodeClutItemChannel(clutItem.m_red);
|
||||
const uint8_t g = DecodeClutItemChannel(clutItem.m_green);
|
||||
const uint8_t b = DecodeClutItemChannel(clutItem.m_blue);
|
||||
return RGBAColor::Create(r, g, b, 255);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user