[Scummvm-cvs-logs] scummvm master -> dbaad1a89633fe51eabb64a910568fe3995734ec
clone2727
clone2727 at gmail.com
Sat Mar 5 01:49:25 CET 2011
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
dbaad1a896 SCI: Fix Mac icon bar palette match order
Commit: dbaad1a89633fe51eabb64a910568fe3995734ec
https://github.com/scummvm/scummvm/commit/dbaad1a89633fe51eabb64a910568fe3995734ec
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-04T16:48:14-08:00
Commit Message:
SCI: Fix Mac icon bar palette match order
Changed paths:
engines/sci/graphics/palette.cpp
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 1b3e259..48a069b 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -858,19 +858,28 @@ void GfxPalette::palVaryProcess(int signal, bool setPalette) {
}
}
+static inline uint getMacColorDiff(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) {
+ // Use the difference of the top 4 bits and add together the differences
+ return ABS((r2 & 0xf0) - (r1 & 0xf0)) + ABS((g2 & 0xf0) - (g1 & 0xf0)) + ABS((b2 & 0xf0) - (b1 & 0xf0));
+}
+
byte GfxPalette::findMacIconBarColor(byte r, byte g, byte b) {
// Find the best color for use with the Mac icon bar
+ // Check white, then the palette colors, and then black
- byte found = 0xFF;
- uint diff = 0xFFFFFFFF;
+ // Try white first
+ byte found = 0xff;
+ uint diff = getMacColorDiff(r, g, b, 0xff, 0xff, 0xff);
- for (uint16 i = 0; i < 256; i++) {
- // Use the difference of the top 4 bits
- int dr = (_macClut[i * 3 ] & 0xf0) - (r & 0xf0);
- int dg = (_macClut[i * 3 + 1] & 0xf0) - (g & 0xf0);
- int db = (_macClut[i * 3 + 2] & 0xf0) - (b & 0xf0);
+ if (diff == 0)
+ return found;
- uint cdiff = ABS(dr) + ABS(dg) + ABS(db);
+ // Go through the main colors of the CLUT
+ for (uint16 i = 1; i < 255; i++) {
+ if (!colorIsFromMacClut(i))
+ continue;
+
+ uint cdiff = getMacColorDiff(r, g, b, _macClut[i * 3], _macClut[i * 3 + 1], _macClut[i * 3 + 2]);
if (cdiff == 0)
return i;
@@ -880,6 +889,10 @@ byte GfxPalette::findMacIconBarColor(byte r, byte g, byte b) {
}
}
+ // Also check black here
+ if (getMacColorDiff(r, g, b, 0, 0, 0) < diff)
+ return 0;
+
return found;
}
More information about the Scummvm-git-logs
mailing list