39 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
40 #ifndef SDL_BIG_ENDIAN
41 #include <SDL_endian.h>
69 const uint8_t blockSize) :
78 if (description[0] ==
'#')
89 else if (description[0] ==
'@')
94 const std::string str = *it;
105 if (color !=
nullptr)
108 color2.
value[3] = alpha;
122 logger->
log(
"Error, invalid embedded palette: %s", description.c_str());
126 const uint8_t blockSize,
129 for (
size_t i = 0, colorIdx = 0;
130 i < blockSize && colorIdx < 4;
133 color.value[colorIdx] =
CAST_U8((
134 hexDecode(hexStr[i]) << 4)
135 + hexDecode(hexStr[i + 1]));
142 if (
'0' <= c && c <=
'9')
144 else if (
'A' <= c && c <=
'F')
146 else if (
'a' <= c && c <=
'f')
167 const int intLast = intensity * last;
168 const int i = intLast / 255;
169 const int t = intLast % 255;
171 int j = t != 0 ? i : i - 1;
178 const int r2 = colorJ.
value[0];
179 const int g2 = colorJ.
value[1];
180 const int b2 = colorJ.
value[2];
192 if (i > 0 && i < last + 1)
195 const int t2 = 255 - t;
197 color[0] = (t2 * colorI.
value[0] + t * r2) / 255;
198 color[1] = (t2 * colorI.
value[1] + t * g2) / 255;
199 color[2] = (t2 * colorI.
value[2] + t * b2) / 255;
204 color[0] = (t * r2) / 255;
205 color[1] = (t * g2) / 255;
206 color[2] = (t * b2) / 255;
220 else if (intensity < 0.0)
224 intensity *=
static_cast<double>(
mColors.size() - 1);
227 const int i =
CAST_S32(floor(intensity));
228 const int j =
CAST_S32(ceil(intensity));
234 color[0] = colorI.
value[0];
235 color[1] = colorI.
value[1];
236 color[2] = colorI.
value[2];
241 const double rest = 1 - intensity;
246 intensity * colorJ.
value[0]);
248 intensity * colorJ.
value[1]);
250 intensity * colorJ.
value[2]);
255 #ifdef SIMD_SUPPORTED
static void initFunctions()
static DyeFunctionPtr funcReplaceAOGLColorSse2
void getColor(const unsigned int intensity, unsigned int(&color)[3]) const
static DyeFunctionPtr funcReplaceSColorAvx2
void replaceAColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceAColorSse2
static DyeFunctionPtr funcReplaceSColor
void replaceAOGLColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceAColor
static DyeFunctionPtr funcReplaceSOGLColor
void replaceSOGLColorDefault(uint32_t *pixels, const int bufSize) const
static void hexToColor(const std::string &hexStr, const uint8_t blockSize, DyeColor &color)
void replaceSColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceSOGLColorSse2
static DyeFunctionPtr funcReplaceSColorSse2
static DyeFunctionPtr funcReplaceAOGLColorAvx2
static unsigned int hexDecode(const signed char c) A_CONST
DyePalette(const std::string &pallete, const uint8_t blockSize)
static DyeFunctionPtr funcReplaceAOGLColor
static DyeFunctionPtr funcReplaceSOGLColorAvx2
static DyeFunctionPtr funcReplaceAColorAvx2
std::vector< DyeColor > mColors
void log(const char *const log_text,...)
void(DyePalette::* DyeFunctionPtr)(uint32_t *pixels, const int bufSize) const
#define FOR_EACH(type, iter, array)
const DyeColor * getColor(const std::string &name)
std::map< std::string, DyeColor > mColors
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect