From b4508cbc995c55a44fe4e6ba8a1d5b41d5fd82a6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Dec 2010 11:52:12 +0000 Subject: [PATCH] Proper fix for .cur loading bug --- panda/src/x11display/x11GraphicsWindow.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 9d2de21187..e5c00114f3 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -2044,14 +2044,12 @@ read_ico(istream &ico) { if (infoHeader.compression != 0) goto cleanup; // Load the color palette, if one exists. - colorCount = entries[entry].colorCount == 0 ? 256 : entries[entry].colorCount; - // FIXME: this is probably not a proper fix: - if (bitsPerPixel == 1) { - colorCount = 2; + if (bitsPerPixel != 24 && bitsPerPixel != 32) { + colorCount = 1 << bitsPerPixel; + palette = new IcoColor[colorCount]; + ico.read(reinterpret_cast(palette), colorCount * sizeof(IcoColor)); + if (!ico.good()) goto cleanup; } - palette = new IcoColor[colorCount]; - if (bitsPerPixel <= 8) ico.read(reinterpret_cast(palette), colorCount * sizeof(IcoColor)); - if (!ico.good()) goto cleanup; // Read in the pixel data. xorBmpSize = (infoHeader.width * (infoHeader.height / 2) * bitsPerPixel) / 8;