Implement DIBINDEX for COLORREF

Glenn Wurster gwurster at scs.carleton.ca
Fri Jun 10 11:50:03 CDT 2005


Changelog:

Adds support for the DIBINDEX type of COLORREF.

Glenn.

--- dlls/x11drv/palette.c	6 May 2005 15:44:32 -0000	1.14
+++ dlls/x11drv/palette.c	10 Jun 2005 16:37:00 -0000
@@ -868,15 +868,26 @@
 	 */
 
 	unsigned 	long red, green, blue;
-	unsigned 	idx = 0;
+	unsigned 	idx = color & 0xffff;
+        RGBQUAD         quad;
 
 	switch(spec_type)
         {
+          case 0x10: /* DIBINDEX */
+            if( X11DRV_GetDIBColorTable( physDev, idx, 1, &quad ) != 1 ) {
+                WARN("DIBINDEX(%lx) : idx %d is out of bounds, assuming black\n", color , idx);
+                GDI_ReleaseObj( hPal );
+                return 0;
+            } else {
+                color = RGB( quad.rgbRed, quad.rgbGreen, quad.rgbBlue );
+            }
+            break;
+                
           case 1: /* PALETTEINDEX */
 
-            if( (idx = color & 0xffff) >= palPtr->logpalette.palNumEntries)
+            if( idx >= palPtr->logpalette.palNumEntries)
             {
-                WARN("RGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
+                WARN("PALETTEINDEX(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
 		GDI_ReleaseObj( hPal );
                 return 0;
             }
@@ -965,7 +976,7 @@
 		index = color & 0xffff;
 
 	        if( index >= palPtr->logpalette.palNumEntries )
-		    WARN("RGB(%lx) : index %i is out of bounds\n", color, index);
+		    WARN("PALETTEINDEX(%lx) : index %i is out of bounds\n", color, index);
 		else if( palPtr->mapping ) index = palPtr->mapping[index];
 
 		/*  TRACE(palette,"PALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);



More information about the wine-patches mailing list