Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarImageProcessing.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-26 21:39:22 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-26 21:39:22 +1000
commitf2fedb0c878120d4887ae9c1c14d4ac1a8881d85 (patch)
treec2608376bbc22ddf3763e21c442c27b36a6cf383 /source/core/StarImageProcessing.cpp
parent14ef69c0f6309d64a358b25cf6395bc80a4c6ff5 (diff)
cache NetworkedAnimator drawables
could use a LruCache later
Diffstat (limited to 'source/core/StarImageProcessing.cpp')
-rw-r--r--source/core/StarImageProcessing.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/source/core/StarImageProcessing.cpp b/source/core/StarImageProcessing.cpp
index f66da30..4dfcf8a 100644
--- a/source/core/StarImageProcessing.cpp
+++ b/source/core/StarImageProcessing.cpp
@@ -174,36 +174,38 @@ ImageOperation imageOperationFromString(StringView string) {
char ch = *ptr;
if (ch == '=' || ch == ';' || ptr == end) {
- char* c = which ? a : b;
-
- if (hexLen == 3) {
- nibbleDecode(hexPtr, 3, c, 4);
- c[0] |= (c[0] << 4);
- c[1] |= (c[1] << 4);
- c[2] |= (c[2] << 4);
- c[3] = 255;
- }
- else if (hexLen == 4) {
- nibbleDecode(hexPtr, 4, c, 4);
- c[0] |= (c[0] << 4);
- c[1] |= (c[1] << 4);
- c[2] |= (c[2] << 4);
- c[3] |= (c[3] << 4);
- }
- else if (hexLen == 6) {
- hexDecode(hexPtr, 6, c, 4);
- c[3] = 255;
- }
- else if (hexLen == 8) {
- hexDecode(hexPtr, 8, c, 4);
- }
- else
- throw ImageOperationException(strf("Improper size for hex string '%s' in imageOperationFromString", StringView(hexPtr, hexLen)), false);
+ if (hexLen != 0) {
+ char* c = which ? a : b;
+
+ if (hexLen == 3) {
+ nibbleDecode(hexPtr, 3, c, 4);
+ c[0] |= (c[0] << 4);
+ c[1] |= (c[1] << 4);
+ c[2] |= (c[2] << 4);
+ c[3] = 255;
+ }
+ else if (hexLen == 4) {
+ nibbleDecode(hexPtr, 4, c, 4);
+ c[0] |= (c[0] << 4);
+ c[1] |= (c[1] << 4);
+ c[2] |= (c[2] << 4);
+ c[3] |= (c[3] << 4);
+ }
+ else if (hexLen == 6) {
+ hexDecode(hexPtr, 6, c, 4);
+ c[3] = 255;
+ }
+ else if (hexLen == 8) {
+ hexDecode(hexPtr, 8, c, 4);
+ }
+ else
+ throw ImageOperationException(strf("Improper size for hex string '%s' in imageOperationFromString", StringView(hexPtr, hexLen)), false);
- if (which = !which)
- operation.colorReplaceMap[*(Vec4B*)&a] = *(Vec4B*)&b;
+ if (which = !which)
+ operation.colorReplaceMap[*(Vec4B*)&a] = *(Vec4B*)&b;
- hexLen = 0;
+ hexLen = 0;
+ }
}
else if (!hexLen++)
hexPtr = ptr;