GetSystemPaletteEntries returns palette size if entries==NULL.
Use this instead of COLOR_GetSystemPaletteSize.
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 2218e3b..0f6a723 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -14,7 +14,6 @@
#include "global.h"
#include "sysmetrics.h"
#include "cursoricon.h"
-#include "color.h"
#include "debug.h"
#include "x11drv.h"
@@ -462,35 +461,40 @@
HANDLE32 WINAPI LoadImage32W( HINSTANCE32 hinst, LPCWSTR name, UINT32 type,
INT32 desiredx, INT32 desiredy, UINT32 loadflags )
{
- if (HIWORD(name)) {
- TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
- hinst,name,type,desiredx,desiredy,loadflags
- );
- } else {
- TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
- hinst,name,type,desiredx,desiredy,loadflags
- );
+ if (HIWORD(name)) {
+ TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
+ hinst,name,type,desiredx,desiredy,loadflags);
+ } else {
+ TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
+ hinst,name,type,desiredx,desiredy,loadflags);
+ }
+ if (loadflags & LR_DEFAULTSIZE) {
+ if (type == IMAGE_ICON) {
+ if (!desiredx) desiredx = SYSMETRICS_CXICON;
+ if (!desiredy) desiredy = SYSMETRICS_CYICON;
+ } else if (type == IMAGE_CURSOR) {
+ if (!desiredx) desiredx = SYSMETRICS_CXCURSOR;
+ if (!desiredy) desiredy = SYSMETRICS_CYCURSOR;
}
- if (loadflags & LR_DEFAULTSIZE)
- {
- if (type == IMAGE_ICON) {
- if (!desiredx) desiredx = SYSMETRICS_CXICON;
- if (!desiredy) desiredy = SYSMETRICS_CYICON;
- } else if (type == IMAGE_CURSOR) {
- if (!desiredx) desiredx = SYSMETRICS_CXCURSOR;
- if (!desiredy) desiredy = SYSMETRICS_CYCURSOR;
- }
}
if (loadflags & LR_LOADFROMFILE) loadflags &= ~LR_SHARED;
switch (type) {
- case IMAGE_BITMAP:
- return BITMAP_LoadBitmap32W(hinst, name, loadflags);
- case IMAGE_ICON:
- return CURSORICON_Load32(hinst, name, desiredx, desiredy,
- MIN(16, COLOR_GetSystemPaletteSize()), FALSE, loadflags);
- case IMAGE_CURSOR:
- return CURSORICON_Load32(hinst, name, desiredx, desiredy, 1, TRUE,
- loadflags);
+ case IMAGE_BITMAP:
+ return BITMAP_LoadBitmap32W(hinst, name, loadflags);
+
+ case IMAGE_ICON:
+ {
+ HDC32 hdc = GetDC32(0);
+ UINT32 palEnts = GetSystemPaletteEntries32(hdc, 0, 0, NULL);
+ ReleaseDC32(0, hdc);
+
+ return CURSORICON_Load32(hinst, name, desiredx, desiredy,
+ MIN(16, palEnts), FALSE, loadflags);
+ }
+
+ case IMAGE_CURSOR:
+ return CURSORICON_Load32(hinst, name, desiredx, desiredy,
+ 1, TRUE, loadflags);
}
return 0;
}
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 060ac3a..2fb2914 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -833,6 +833,10 @@
*/
HICON16 WINAPI LoadIcon16( HINSTANCE16 hInstance, SEGPTR name )
{
+ HDC32 hdc = GetDC32(0);
+ UINT32 palEnts = GetSystemPaletteEntries32(hdc, 0, 0, NULL);
+ ReleaseDC32(0, hdc);
+
if (HIWORD(name))
TRACE(icon, "%04x '%s'\n",
hInstance, (char *)PTR_SEG_TO_LIN( name ) );
@@ -842,7 +846,7 @@
return CURSORICON_Load16( hInstance, name,
SYSMETRICS_CXICON, SYSMETRICS_CYICON,
- MIN( 16, COLOR_GetSystemPaletteSize() ), FALSE, 0);
+ MIN(16, palEnts), FALSE, 0);
}
@@ -1294,7 +1298,11 @@
UINT16 retVal = 0;
if( dir && !dir->idReserved && (dir->idType & 3) )
{
- int colors = (cFlag & LR_MONOCHROME) ? 2 : COLOR_GetSystemPaletteSize();
+ HDC32 hdc = GetDC32(0);
+ UINT32 palEnts = GetSystemPaletteEntries32(hdc, 0, 0, NULL);
+ int colors = (cFlag & LR_MONOCHROME) ? 2 : palEnts;
+ ReleaseDC32(0, hdc);
+
if( bIcon )
{
ICONDIRENTRY* entry;
@@ -1484,9 +1492,13 @@
*/
HICON32 WINAPI LoadIcon32W(HINSTANCE32 hInstance, LPCWSTR name)
{
+ HDC32 hdc = GetDC32(0);
+ UINT32 palEnts = GetSystemPaletteEntries32(hdc, 0, 0, NULL);
+ ReleaseDC32(0, hdc);
+
return CURSORICON_Load32( hInstance, name,
SYSMETRICS_CXICON, SYSMETRICS_CYICON,
- MIN( 16, COLOR_GetSystemPaletteSize() ), FALSE, 0);
+ MIN( 16, palEnts ), FALSE, 0);
}
/***********************************************************************
diff --git a/objects/dib.c b/objects/dib.c
index 82226fb..6d12b28 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -11,7 +11,6 @@
#include "bitmap.h"
#include "callback.h"
#include "palette.h"
-#include "color.h"
#include "global.h"
#include "debug.h"
#include "x11drv.h"
diff --git a/objects/palette.c b/objects/palette.c
index 950b5cc..b6179a7 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -421,6 +421,7 @@
TRACE(palette, "hdc=%04x,start=%i,count=%i\n", hdc,start,count);
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
+ if (!entries) return COLOR_GetSystemPaletteSize();
if (start >= dc->w.devCaps->sizePalette)
{
GDI_HEAP_UNLOCK( hdc );