diff --git a/objects/palette.c b/objects/palette.c index fa569970c2d..60a6c922c7d 100644 --- a/objects/palette.c +++ b/objects/palette.c @@ -150,12 +150,15 @@ HPALETTE16 WINAPI CreateHalftonePalette16( * 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 @@ HPALETTE WINAPI CreateHalftonePalette( 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 @@ UINT WINAPI GetPaletteEntries( 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;