Implement NtGdiAnimatePalette (partly ripped from Wine)
by hpussin
Modified: trunk/reactos/lib/gdi32/gdi32.def
Modified: trunk/reactos/lib/gdi32/misc/stubs.c
Modified: trunk/reactos/subsys/win32k/objects/color.c

Modified: trunk/reactos/lib/gdi32/gdi32.def
--- trunk/reactos/lib/gdi32/gdi32.def	2005-05-28 12:15:11 UTC (rev 15576)
+++ trunk/reactos/lib/gdi32/gdi32.def	2005-05-28 12:43:26 UTC (rev 15577)
@@ -17,7 +17,7 @@
 AddFontResourceW@4
 AddFontResourceTracking@8
 AngleArc@24
-AnimatePalette@16
+AnimatePalette@16=NtGdiAnimatePalette@16
 AnyLinkedFonts@0
 Arc@36=NtGdiArc@36
 ArcTo@36=NtGdiArcTo@36

Modified: trunk/reactos/lib/gdi32/misc/stubs.c
--- trunk/reactos/lib/gdi32/misc/stubs.c	2005-05-28 12:15:11 UTC (rev 15576)
+++ trunk/reactos/lib/gdi32/misc/stubs.c	2005-05-28 12:43:26 UTC (rev 15577)
@@ -13,25 +13,10 @@
 
 #define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try again later.\n", __FUNCTION__);
 
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-AnimatePalette(
-	HPALETTE		a0,
-	UINT			a1,
-	UINT			a2,
-	CONST PALETTEENTRY	*a3
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return FALSE;
-}
 
 
 
+
 /*
  * @unimplemented
  */

Modified: trunk/reactos/subsys/win32k/objects/color.c
--- trunk/reactos/subsys/win32k/objects/color.c	2005-05-28 12:15:11 UTC (rev 15576)
+++ trunk/reactos/subsys/win32k/objects/color.c	2005-05-28 12:43:26 UTC (rev 15577)
@@ -70,12 +70,57 @@
    return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
 }
 
-BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPalette, UINT uStartIndex,
-   UINT uEntries, CONST PPALETTEENTRY ppe)
+BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex,
+   UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
 {
-   UNIMPLEMENTED;
-   SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
-   return FALSE;
+    if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
+    {
+        PPALGDI palPtr;
+        UINT pal_entries;
+        HDC hDC;
+        PDC dc;	
+		HWND hHwd;
+        const PALETTEENTRY *pptr = PaletteColors;
+ 
+        palPtr = (PPALGDI)PALETTE_LockPalette(hPal);
+        if (!palPtr) return FALSE;
+ 
+        pal_entries = palPtr->NumColors;
+        if (StartIndex >= pal_entries)
+        {
+          PALETTE_UnlockPalette(hPal);
+          return FALSE;
+        }
+        if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
+ 
+        for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) {
+          /* According to MSDN, only animate PC_RESERVED colours */
+          if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED) {
+            memcpy( &palPtr->IndexedColors[StartIndex], pptr,
+                    sizeof(PALETTEENTRY) );
+            PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1);
+          }
+        }
+ 
+        PALETTE_UnlockPalette(hPal);
+ 
+        /* Immediately apply the new palette if current window uses it */		
+		hHwd = NtUserGetDesktopWindow();
+        hDC =  (HDC)NtUserGetWindowDC(hHwd);
+        dc = DC_LockDc(hDC);
+        if (NULL != dc)
+        {
+          if (dc->w.hPalette == hPal)
+          {
+            DC_UnlockDc(hDC);
+            NtGdiRealizePalette(hDC);
+          }
+          else
+            DC_UnlockDc(hDC);
+        }		
+		NtUserReleaseDC(hHwd,hDC);   
+    }
+    return TRUE;
 }
 
 HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC  hDC)