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
106e7fb5
Commit
106e7fb5
authored
Jul 23, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Add support for adding trasparent color to generated palettes.
parent
0be2718b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
52 deletions
+128
-52
palette.c
dlls/windowscodecs/palette.c
+54
-28
palette.c
dlls/windowscodecs/tests/palette.c
+74
-24
No files found.
dlls/windowscodecs/palette.c
View file @
106e7fb5
...
...
@@ -133,13 +133,13 @@ static WICColor *generate_gray256_palette(UINT *count)
return
entries
;
}
static
WICColor
*
generate_halftone8_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone8_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
16
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
16
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
17
:
16
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
8
;
i
++
)
...
...
@@ -157,16 +157,20 @@ static WICColor *generate_halftone8_palette(UINT *count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
8
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone27_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone27_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
28
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
28
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
29
:
28
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
27
;
i
++
)
...
...
@@ -178,17 +182,20 @@ static WICColor *generate_halftone27_palette(UINT *count)
entries
[
i
]
|=
halftone_values
[(
i
/
9
)
%
3
]
<<
16
;
}
entries
[
i
]
=
0xffc0c0c0
;
entries
[
i
++
]
=
0xffc0c0c0
;
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone64_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone64_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
72
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
72
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
73
:
72
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
64
;
i
++
)
...
...
@@ -207,16 +214,20 @@ static WICColor *generate_halftone64_palette(UINT *count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
64
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone125_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone125_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
126
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
126
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
127
:
126
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
125
;
i
++
)
...
...
@@ -228,17 +239,20 @@ static WICColor *generate_halftone125_palette(UINT *count)
entries
[
i
]
|=
halftone_values
[(
i
/
25
)
%
5
]
<<
16
;
}
entries
[
i
]
=
0xffc0c0c0
;
entries
[
i
++
]
=
0xffc0c0c0
;
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone216_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone216_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
224
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
224
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
225
:
224
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
216
;
i
++
)
...
...
@@ -257,16 +271,20 @@ static WICColor *generate_halftone216_palette(UINT *count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
216
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone252_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone252_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
*
count
=
252
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
252
*
sizeof
(
WICColor
));
*
count
=
add_transparent
?
253
:
252
;
entries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
count
*
sizeof
(
WICColor
));
if
(
!
entries
)
return
NULL
;
for
(
i
=
0
;
i
<
252
;
i
++
)
...
...
@@ -278,10 +296,14 @@ static WICColor *generate_halftone252_palette(UINT *count)
entries
[
i
]
|=
halftone_values_g
[(
i
/
6
)
%
7
]
<<
8
;
entries
[
i
]
|=
halftone_values_rb
[(
i
/
42
)
%
6
]
<<
16
;
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
return
entries
;
}
static
WICColor
*
generate_halftone256_palette
(
UINT
*
count
)
static
WICColor
*
generate_halftone256_palette
(
UINT
*
count
,
BOOL
add_transparent
)
{
WICColor
*
entries
;
UINT
i
;
...
...
@@ -299,6 +321,10 @@ static WICColor *generate_halftone256_palette(UINT *count)
entries
[
i
]
|=
halftone_values_gr
[(
i
/
4
)
%
8
]
<<
8
;
entries
[
i
]
|=
halftone_values_gr
[(
i
/
32
)
%
8
]
<<
16
;
}
if
(
add_transparent
)
entries
[
255
]
=
0
;
return
entries
;
}
...
...
@@ -342,37 +368,37 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
break
;
case
WICBitmapPaletteTypeFixedHalftone8
:
colors
=
generate_halftone8_palette
(
&
count
);
colors
=
generate_halftone8_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone27
:
colors
=
generate_halftone27_palette
(
&
count
);
colors
=
generate_halftone27_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone64
:
colors
=
generate_halftone64_palette
(
&
count
);
colors
=
generate_halftone64_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone125
:
colors
=
generate_halftone125_palette
(
&
count
);
colors
=
generate_halftone125_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone216
:
colors
=
generate_halftone216_palette
(
&
count
);
colors
=
generate_halftone216_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone252
:
colors
=
generate_halftone252_palette
(
&
count
);
colors
=
generate_halftone252_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
case
WICBitmapPaletteTypeFixedHalftone256
:
colors
=
generate_halftone256_palette
(
&
count
);
colors
=
generate_halftone256_palette
(
&
count
,
add_transparent
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
break
;
...
...
dlls/windowscodecs/tests/palette.c
View file @
106e7fb5
...
...
@@ -176,11 +176,14 @@ static void generate_gray256_palette(DWORD *entries, UINT count)
}
}
static
void
generate_halftone8_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone8_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
UINT
i
;
assert
(
count
==
16
);
if
(
add_transparent
)
ok
(
count
==
17
,
"expected 17, got %u
\n
"
,
count
);
else
ok
(
count
==
16
,
"expected 16, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
...
...
@@ -197,14 +200,20 @@ static void generate_halftone8_palette(DWORD *entries, UINT count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
8
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone27_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone27_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values
[
4
]
=
{
0x00
,
0x80
,
0xff
};
UINT
i
;
assert
(
count
==
28
);
if
(
add_transparent
)
ok
(
count
==
29
,
"expected 29, got %u
\n
"
,
count
);
else
ok
(
count
==
28
,
"expected 28, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
27
;
i
++
)
{
...
...
@@ -214,15 +223,20 @@ static void generate_halftone27_palette(DWORD *entries, UINT count)
entries
[
i
]
|=
halftone_values
[(
i
/
9
)
%
3
]
<<
16
;
}
entries
[
i
]
=
0xffc0c0c0
;
entries
[
i
++
]
=
0xffc0c0c0
;
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone64_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone64_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values
[
4
]
=
{
0x00
,
0x55
,
0xaa
,
0xff
};
UINT
i
;
assert
(
count
==
72
);
if
(
add_transparent
)
ok
(
count
==
73
,
"expected 73, got %u
\n
"
,
count
);
else
ok
(
count
==
72
,
"expected 72, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
64
;
i
++
)
{
...
...
@@ -239,14 +253,20 @@ static void generate_halftone64_palette(DWORD *entries, UINT count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
64
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone125_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone125_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values
[
5
]
=
{
0x00
,
0x40
,
0x80
,
0xbf
,
0xff
};
static
const
BYTE
halftone_values
[
5
]
=
{
0x00
,
0x40
,
0x80
,
0xbf
,
0xff
};
UINT
i
;
assert
(
count
==
126
);
if
(
add_transparent
)
ok
(
count
==
127
,
"expected 127, got %u
\n
"
,
count
);
else
ok
(
count
==
126
,
"expected 126, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
125
;
i
++
)
{
...
...
@@ -256,15 +276,20 @@ static void generate_halftone125_palette(DWORD *entries, UINT count)
entries
[
i
]
|=
halftone_values
[(
i
/
25
)
%
5
]
<<
16
;
}
entries
[
i
]
=
0xffc0c0c0
;
entries
[
i
++
]
=
0xffc0c0c0
;
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone216_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone216_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values
[
6
]
=
{
0x00
,
0x33
,
0x66
,
0x99
,
0xcc
,
0xff
};
UINT
i
;
assert
(
count
==
224
);
if
(
add_transparent
)
ok
(
count
==
225
,
"expected 225, got %u
\n
"
,
count
);
else
ok
(
count
==
224
,
"expected 224, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
216
;
i
++
)
{
...
...
@@ -281,15 +306,21 @@ static void generate_halftone216_palette(DWORD *entries, UINT count)
entries
[
i
]
=
0xff000000
;
entries
[
i
]
|=
halftone
[
i
-
216
];
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone252_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone252_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values_rb
[
6
]
=
{
0x00
,
0x33
,
0x66
,
0x99
,
0xcc
,
0xff
};
static
const
BYTE
halftone_values_g
[
7
]
=
{
0x00
,
0x2b
,
0x55
,
0x80
,
0xaa
,
0xd5
,
0xff
};
UINT
i
;
assert
(
count
==
252
);
if
(
add_transparent
)
ok
(
count
==
253
,
"expected 253, got %u
\n
"
,
count
);
else
ok
(
count
==
252
,
"expected 252, got %u
\n
"
,
count
);
for
(
i
=
0
;
i
<
252
;
i
++
)
{
...
...
@@ -298,9 +329,12 @@ static void generate_halftone252_palette(DWORD *entries, UINT count)
entries
[
i
]
|=
halftone_values_g
[(
i
/
6
)
%
7
]
<<
8
;
entries
[
i
]
|=
halftone_values_rb
[(
i
/
42
)
%
6
]
<<
16
;
}
if
(
add_transparent
)
entries
[
i
]
=
0
;
}
static
void
generate_halftone256_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_halftone256_palette
(
DWORD
*
entries
,
UINT
count
,
BOOL
add_transparent
)
{
static
const
BYTE
halftone_values_b
[
4
]
=
{
0x00
,
0x55
,
0xaa
,
0xff
};
static
const
BYTE
halftone_values_gr
[
8
]
=
{
0x00
,
0x24
,
0x49
,
0x6d
,
0x92
,
0xb6
,
0xdb
,
0xff
};
...
...
@@ -315,6 +349,9 @@ static void generate_halftone256_palette(DWORD *entries, UINT count)
entries
[
i
]
|=
halftone_values_gr
[(
i
/
4
)
%
8
]
<<
8
;
entries
[
i
]
|=
halftone_values_gr
[(
i
/
32
)
%
8
]
<<
16
;
}
if
(
add_transparent
)
entries
[
255
]
=
0
;
}
static
void
test_predefined_palette
(
void
)
...
...
@@ -325,20 +362,33 @@ static void test_predefined_palette(void)
BOOL
is_bw
,
is_gray
;
UINT
count
;
WICColor
color
[
256
];
BOOL
add_transparent
;
}
td
[]
=
{
{
WICBitmapPaletteTypeFixedBW
,
1
,
1
,
2
,
{
0xff000000
,
0xffffffff
}
},
{
WICBitmapPaletteTypeFixedBW
,
1
,
1
,
2
,
{
0xff000000
,
0xffffffff
},
1
},
{
WICBitmapPaletteTypeFixedGray4
,
0
,
1
,
4
,
{
0xff000000
,
0xff555555
,
0xffaaaaaa
,
0xffffffff
}
},
{
WICBitmapPaletteTypeFixedGray4
,
0
,
1
,
4
,
{
0xff000000
,
0xff555555
,
0xffaaaaaa
,
0xffffffff
},
1
},
{
WICBitmapPaletteTypeFixedGray16
,
0
,
1
,
16
,
{
0
}
},
{
WICBitmapPaletteTypeFixedGray16
,
0
,
1
,
16
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedGray256
,
0
,
1
,
256
,
{
0
}
},
{
WICBitmapPaletteTypeFixedGray256
,
0
,
1
,
256
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone8
,
0
,
0
,
16
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone8
,
0
,
0
,
17
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone27
,
0
,
0
,
28
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone27
,
0
,
0
,
29
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone64
,
0
,
0
,
72
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone64
,
0
,
0
,
73
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone125
,
0
,
0
,
126
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone125
,
0
,
0
,
127
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone216
,
0
,
0
,
224
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone216
,
0
,
0
,
225
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone252
,
0
,
0
,
252
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone252
,
0
,
0
,
253
,
{
0
},
1
},
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
},
1
}
};
IWICImagingFactory
*
factory
;
IWICPalette
*
palette
;
...
...
@@ -357,7 +407,7 @@ static void test_predefined_palette(void)
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
hr
==
S_OK
,
"%u: CreatePalette error %#x
\n
"
,
i
,
hr
);
hr
=
IWICPalette_InitializePredefined
(
palette
,
td
[
i
].
type
,
FALSE
);
hr
=
IWICPalette_InitializePredefined
(
palette
,
td
[
i
].
type
,
td
[
i
].
add_transparent
);
ok
(
hr
==
S_OK
,
"%u: InitializePredefined error %#x
\n
"
,
i
,
hr
);
bret
=
-
1
;
...
...
@@ -394,19 +444,19 @@ static void test_predefined_palette(void)
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedGray256
)
generate_gray256_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone8
)
generate_halftone8_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone8_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone27
)
generate_halftone27_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone27_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone64
)
generate_halftone64_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone64_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone125
)
generate_halftone125_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone125_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone216
)
generate_halftone216_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone216_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone252
)
generate_halftone252_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone252_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
else
if
(
td
[
i
].
type
==
WICBitmapPaletteTypeFixedHalftone256
)
generate_halftone256_palette
(
td
[
i
].
color
,
td
[
i
].
count
);
generate_halftone256_palette
(
td
[
i
].
color
,
td
[
i
].
count
,
td
[
i
].
add_transparent
);
for
(
j
=
0
;
j
<
count
;
j
++
)
{
...
...
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