aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2012-06-20 18:39:03 +0200
committerNarek Mailian2013-08-08 08:35:07 +0200
commit969a33a32dc331ec8d89da056e584a68974dfeec (patch)
tree7a7e5d9737ea0822fad11a8f6a44798a2f7c1fff
parentece8b7fb65402238ab7df896361a9cefe28b8897 (diff)
downloadscummvm-rg350-969a33a32dc331ec8d89da056e584a68974dfeec.tar.gz
scummvm-rg350-969a33a32dc331ec8d89da056e584a68974dfeec.tar.bz2
scummvm-rg350-969a33a32dc331ec8d89da056e584a68974dfeec.zip
GUI: Allow GUI cursor creation to work with abitrary 2/4Bpp formats.
-rw-r--r--gui/ThemeEngine.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 0f8b449b58..2ba45a4bc3 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1320,22 +1320,31 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
memset(_cursor, 0xFF, sizeof(byte) * _cursorWidth * _cursorHeight);
// the transparent color is 0xFF00FF
- const int colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF);
+ const uint32 colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF);
// Now, scan the bitmap. We have to convert it from 16 bit color mode
// to 8 bit mode, and have to create a suitable palette on the fly.
uint colorsFound = 0;
Common::HashMap<int, int> colorToIndex;
- const OverlayColor *src = (const OverlayColor *)cursor->getPixels();
+ const byte *src = (const byte *)cursor->getPixels();
for (uint y = 0; y < _cursorHeight; ++y) {
for (uint x = 0; x < _cursorWidth; ++x) {
+ uint32 color = colTransparent;
byte r, g, b;
+ if (cursor->format.bytesPerPixel == 2) {
+ color = READ_UINT16(src);
+ } else if (cursor->format.bytesPerPixel == 4) {
+ color = READ_UINT32(src);
+ }
+
+ src += cursor->format.bytesPerPixel;
+
// Skip transparency
- if (src[x] == colTransparent)
+ if (color == colTransparent)
continue;
- _overlayFormat.colorToRGB(src[x], r, g, b);
+ cursor->format.colorToRGB(color, r, g, b);
const int col = (r << 16) | (g << 8) | b;
// If there is no entry yet for this color in the palette: Add one
@@ -1357,7 +1366,6 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
const int index = colorToIndex[col];
_cursor[y * _cursorWidth + x] = index;
}
- src += _cursorWidth;
}
_useCursor = true;