Halftone palette from CW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modified files:
	objects		: palette.c

Log message:
	Codeweavers
	Reimplementation of halftone palettes.




Index: objects/palette.c
===================================================================
RCS file: /home/wine/wine/objects/palette.c,v
retrieving revision 1.38
diff -u -r1.38 palette.c
--- objects/palette.c	2001/07/28 00:18:05	1.38
+++ objects/palette.c	2002/01/27 02:25:35
@@ -150,12 +150,15 @@
  *    Success: Handle to logical halftone palette
  *    Failure: 0
  *
- * FIXME: not truly tested
+ * FIXME: This simply creates the halftone palette dirived from runing
+ *        tests on an windows NT machine. this is assuming a color depth
+ *        of greater that 256 color. On a 256 color device the halftone
+ *        palette will be differnt and this funtion will be incorrect
  */
 HPALETTE WINAPI CreateHalftonePalette(
     HDC hdc) /* [in] Handle to device context */
 {
-    int i, r, g, b;
+    int i;
     struct {
 	WORD Version;
 	WORD NumberOfEntries;
@@ -166,24 +169,71 @@
     Palette.NumberOfEntries = 256;
     GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
 
-    for (r = 0; r < 6; r++) {
-	for (g = 0; g < 6; g++) {
-	    for (b = 0; b < 6; b++) {
-		i = r + g*6 + b*36 + 10;
-		Palette.aEntries[i].peRed = r * 51;
-		Palette.aEntries[i].peGreen = g * 51;
-		Palette.aEntries[i].peBlue = b * 51;
-	    }    
-	  }
-	}
-	
-    for (i = 216; i < 246; i++) {
-	int v = (i - 216) * 8;
-	Palette.aEntries[i].peRed = v;
-	Palette.aEntries[i].peGreen = v;
-	Palette.aEntries[i].peBlue = v;
-	}
-	
+    Palette.NumberOfEntries = 20;
+
+    for (i = 0; i < Palette.NumberOfEntries; i++)
+    {
+        Palette.aEntries[i].peRed=0xff;
+        Palette.aEntries[i].peGreen=0xff;
+        Palette.aEntries[i].peBlue=0xff;
+        Palette.aEntries[i].peFlags=0x00;
+    }
+
+    Palette.aEntries[0].peRed=0x00;
+    Palette.aEntries[0].peBlue=0x00;
+    Palette.aEntries[0].peGreen=0x00;
+
+    /* the first 6 */
+    for (i=1; i <= 6; i++)
+    {
+        Palette.aEntries[i].peRed=(i%2)?0x80:0;
+        Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0;
+        Palette.aEntries[i].peBlue=(i>3)?0x80:0;
+    }
+    
+    for (i=7;  i <= 12; i++)
+    {
+        switch(i)
+        {
+            case 7:
+                Palette.aEntries[i].peRed=0xc0;
+                Palette.aEntries[i].peBlue=0xc0;
+                Palette.aEntries[i].peGreen=0xc0;
+                break;
+            case 8:
+                Palette.aEntries[i].peRed=0xc0;
+                Palette.aEntries[i].peGreen=0xdc;
+                Palette.aEntries[i].peBlue=0xc0;
+                break;
+            case 9:
+                Palette.aEntries[i].peRed=0xa6;
+                Palette.aEntries[i].peGreen=0xca;
+                Palette.aEntries[i].peBlue=0xf0;
+                break;
+            case 10:    
+                Palette.aEntries[i].peRed=0xff;
+                Palette.aEntries[i].peGreen=0xfb;
+                Palette.aEntries[i].peBlue=0xf0;
+                break;
+            case 11:
+                Palette.aEntries[i].peRed=0xa0;
+                Palette.aEntries[i].peGreen=0xa0;
+                Palette.aEntries[i].peBlue=0xa4;
+                break;
+            case 12:
+                Palette.aEntries[i].peRed=0x80;
+                Palette.aEntries[i].peGreen=0x80;
+                Palette.aEntries[i].peBlue=0x80;
+        }
+    }
+
+   for (i=13; i <= 18; i++)
+    {
+        Palette.aEntries[i].peRed=(i%2)?0xff:0;
+        Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0;
+        Palette.aEntries[i].peBlue=(i>15)?0xff:0x00;
+    }
+
     return CreatePalette((LOGPALETTE *)&Palette);
 }
 
@@ -218,6 +268,14 @@
         
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
+    
+    /* NOTE: not documented but test show this to be the case */
+    if (count == 0)
+    {   
+        int rc = palPtr->logpalette.palNumEntries;
+	    GDI_ReleaseObj( hpalette );
+        return rc;
+    }
 
     numEntries = palPtr->logpalette.palNumEntries;
     if (start+count > numEntries) count = numEntries - start;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux