Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c5895ead
Commit
c5895ead
authored
Dec 12, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Use the default DIB color table to create system and halftone palettes.
parent
3a9cabb8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
120 deletions
+70
-120
palette.c
dlls/gdi32/palette.c
+31
-120
palette.c
dlls/gdi32/tests/palette.c
+39
-0
No files found.
dlls/gdi32/palette.c
View file @
c5895ead
...
...
@@ -72,40 +72,6 @@ static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
static
HPALETTE
hPrimaryPalette
=
0
;
/* used for WM_PALETTECHANGED */
static
HPALETTE
hLastRealizedPalette
=
0
;
/* UnrealizeObject() needs it */
#define NB_RESERVED_COLORS 20
/* number of fixed colors in system palette */
static
const
PALETTEENTRY
sys_pal_template
[
NB_RESERVED_COLORS
]
=
{
/* first 10 entries in the system palette */
/* red green blue flags */
{
0x00
,
0x00
,
0x00
,
0
},
{
0x80
,
0x00
,
0x00
,
0
},
{
0x00
,
0x80
,
0x00
,
0
},
{
0x80
,
0x80
,
0x00
,
0
},
{
0x00
,
0x00
,
0x80
,
0
},
{
0x80
,
0x00
,
0x80
,
0
},
{
0x00
,
0x80
,
0x80
,
0
},
{
0xc0
,
0xc0
,
0xc0
,
0
},
{
0xc0
,
0xdc
,
0xc0
,
0
},
{
0xa6
,
0xca
,
0xf0
,
0
},
/* ... c_min/2 dynamic colorcells */
/* ... gap (for sparse palettes) */
/* ... c_min/2 dynamic colorcells */
{
0xff
,
0xfb
,
0xf0
,
0
},
{
0xa0
,
0xa0
,
0xa4
,
0
},
{
0x80
,
0x80
,
0x80
,
0
},
{
0xff
,
0x00
,
0x00
,
0
},
{
0x00
,
0xff
,
0x00
,
0
},
{
0xff
,
0xff
,
0x00
,
0
},
{
0x00
,
0x00
,
0xff
,
0
},
{
0xff
,
0x00
,
0xff
,
0
},
{
0x00
,
0xff
,
0xff
,
0
},
{
0xff
,
0xff
,
0xff
,
0
}
/* last 10 */
};
/***********************************************************************
* PALETTE_Init
...
...
@@ -114,21 +80,30 @@ static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS] =
*/
HPALETTE
PALETTE_Init
(
void
)
{
HPALETTE
hpalette
;
LOGPALETTE
*
palPtr
;
const
RGBQUAD
*
entries
=
get_default_color_table
(
8
);
char
buffer
[
FIELD_OFFSET
(
LOGPALETTE
,
palPalEntry
[
20
]
)];
LOGPALETTE
*
palPtr
=
(
LOGPALETTE
*
)
buffer
;
int
i
;
/* create default palette (20 system colors) */
palPtr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
LOGPALETTE
)
+
(
NB_RESERVED_COLORS
-
1
)
*
sizeof
(
PALETTEENTRY
));
if
(
!
palPtr
)
return
FALSE
;
palPtr
->
palVersion
=
0x300
;
palPtr
->
palNumEntries
=
NB_RESERVED_COLORS
;
memcpy
(
palPtr
->
palPalEntry
,
sys_pal_template
,
sizeof
(
sys_pal_template
)
);
hpalette
=
CreatePalette
(
palPtr
);
HeapFree
(
GetProcessHeap
(),
0
,
palPtr
);
return
hpalette
;
palPtr
->
palNumEntries
=
20
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
palPtr
->
palPalEntry
[
i
].
peRed
=
entries
[
i
].
rgbRed
;
palPtr
->
palPalEntry
[
i
].
peGreen
=
entries
[
i
].
rgbGreen
;
palPtr
->
palPalEntry
[
i
].
peBlue
=
entries
[
i
].
rgbBlue
;
palPtr
->
palPalEntry
[
i
].
peFlags
=
0
;
}
for
(
i
=
10
;
i
<
20
;
i
++
)
{
palPtr
->
palPalEntry
[
i
].
peRed
=
entries
[
236
+
i
].
rgbRed
;
palPtr
->
palPalEntry
[
i
].
peGreen
=
entries
[
236
+
i
].
rgbGreen
;
palPtr
->
palPalEntry
[
i
].
peBlue
=
entries
[
236
+
i
].
rgbBlue
;
palPtr
->
palPalEntry
[
i
].
peFlags
=
0
;
}
return
CreatePalette
(
palPtr
);
}
...
...
@@ -151,8 +126,6 @@ HPALETTE WINAPI CreatePalette(
if
(
!
palette
)
return
0
;
TRACE
(
"entries=%i
\n
"
,
palette
->
palNumEntries
);
size
=
sizeof
(
LOGPALETTE
)
+
(
palette
->
palNumEntries
-
1
)
*
sizeof
(
PALETTEENTRY
);
if
(
!
(
palettePtr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
palettePtr
)
)))
return
0
;
palettePtr
->
unrealize
=
NULL
;
palettePtr
->
version
=
palette
->
palVersion
;
...
...
@@ -191,83 +164,21 @@ HPALETTE WINAPI CreatePalette(
HPALETTE
WINAPI
CreateHalftonePalette
(
HDC
hdc
)
/* [in] Handle to device context */
{
const
RGBQUAD
*
entries
=
get_default_color_table
(
8
);
char
buffer
[
FIELD_OFFSET
(
LOGPALETTE
,
palPalEntry
[
256
]
)];
LOGPALETTE
*
pal
=
(
LOGPALETTE
*
)
buffer
;
int
i
;
struct
{
WORD
Version
;
WORD
NumberOfEntries
;
PALETTEENTRY
aEntries
[
256
];
}
Palette
;
Palette
.
Version
=
0x300
;
Palette
.
NumberOfEntries
=
256
;
GetSystemPaletteEntries
(
hdc
,
0
,
256
,
Palette
.
aEntries
);
Palette
.
NumberOfEntries
=
20
;
for
(
i
=
0
;
i
<
Palette
.
NumberOfEntries
;
i
++
)
pal
->
palVersion
=
0x300
;
pal
->
palNumEntries
=
256
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
Palette
.
aEntries
[
i
].
peRed
=
0xff
;
Palette
.
aEntries
[
i
].
peGreen
=
0xff
;
Palette
.
aEntries
[
i
].
peBlue
=
0xff
;
Palette
.
aEntries
[
i
].
peFlags
=
0x0
0
;
pal
->
palPalEntry
[
i
].
peRed
=
entries
[
i
].
rgbRed
;
pal
->
palPalEntry
[
i
].
peGreen
=
entries
[
i
].
rgbGreen
;
pal
->
palPalEntry
[
i
].
peBlue
=
entries
[
i
].
rgbBlue
;
pal
->
palPalEntry
[
i
].
peFlags
=
0
;
}
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
);
return
CreatePalette
(
pal
);
}
...
...
dlls/gdi32/tests/palette.c
View file @
c5895ead
...
...
@@ -144,8 +144,47 @@ static void test_palette_entries(void)
ok
(
palEntry
.
peFlags
==
getEntryResult
.
peFlags
,
"palEntry.peFlags (%#x) != getEntryResult.peFlags (%#x)
\n
"
,
palEntry
.
peFlags
,
getEntryResult
.
peFlags
);
}
static
void
test_halftone_palette
(
void
)
{
HDC
hdc
;
HPALETTE
pal
;
PALETTEENTRY
entries
[
256
];
PALETTEENTRY
defpal
[
20
];
int
i
,
count
;
hdc
=
GetDC
(
0
);
count
=
GetPaletteEntries
(
GetStockObject
(
DEFAULT_PALETTE
),
0
,
20
,
defpal
);
ok
(
count
==
20
,
"wrong size %u
\n
"
,
count
);
pal
=
CreateHalftonePalette
(
hdc
);
count
=
GetPaletteEntries
(
pal
,
0
,
256
,
entries
);
ok
(
count
==
256
||
broken
(
count
==
20
),
/* nt 4 */
"wrong size %u
\n
"
,
count
);
/* first and last 10 match the default palette */
for
(
i
=
0
;
i
<
10
;
i
++
)
ok
(
entries
[
i
].
peRed
==
defpal
[
i
].
peRed
&&
entries
[
i
].
peGreen
==
defpal
[
i
].
peGreen
&&
entries
[
i
].
peBlue
==
defpal
[
i
].
peBlue
&&
!
entries
[
i
].
peFlags
,
"%u: wrong color %02x,%02x,%02x,%02x
\n
"
,
i
,
entries
[
i
].
peRed
,
entries
[
i
].
peGreen
,
entries
[
i
].
peBlue
,
entries
[
i
].
peFlags
);
for
(
i
=
count
-
10
;
i
<
count
;
i
++
)
ok
(
entries
[
i
].
peRed
==
defpal
[
i
-
count
+
20
].
peRed
&&
entries
[
i
].
peGreen
==
defpal
[
i
-
count
+
20
].
peGreen
&&
entries
[
i
].
peBlue
==
defpal
[
i
-
count
+
20
].
peBlue
&&
!
entries
[
i
].
peFlags
,
"%u: wrong color %02x,%02x,%02x,%02x
\n
"
,
i
,
entries
[
i
].
peRed
,
entries
[
i
].
peGreen
,
entries
[
i
].
peBlue
,
entries
[
i
].
peFlags
);
DeleteObject
(
pal
);
ReleaseDC
(
0
,
hdc
);
}
START_TEST
(
palette
)
{
test_DIB_PAL_COLORS
();
test_palette_entries
();
test_halftone_palette
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment