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
8ff77999
Commit
8ff77999
authored
Jul 16, 2023
by
Jeff Smith
Committed by
Alexandre Julliard
Jul 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Factor out common GIF palette copying logic.
parent
70a6ac07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
52 deletions
+40
-52
gifformat.c
dlls/windowscodecs/gifformat.c
+40
-52
No files found.
dlls/windowscodecs/gifformat.c
View file @
8ff77999
...
...
@@ -701,14 +701,49 @@ static HRESULT WINAPI GifFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
return
S_OK
;
}
static
void
copy_palette
(
ColorMapObject
*
cm
,
Extensions
*
extensions
,
int
count
,
WICColor
*
colors
)
{
int
i
;
if
(
cm
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
colors
[
i
]
=
0xff000000
|
/* alpha */
cm
->
Colors
[
i
].
Red
<<
16
|
cm
->
Colors
[
i
].
Green
<<
8
|
cm
->
Colors
[
i
].
Blue
;
}
}
else
{
colors
[
0
]
=
0xff000000
;
colors
[
1
]
=
0xffffffff
;
for
(
i
=
2
;
i
<
count
;
i
++
)
colors
[
i
]
=
0xff000000
;
}
/* look for the transparent color extension */
for
(
i
=
0
;
i
<
extensions
->
ExtensionBlockCount
;
i
++
)
{
ExtensionBlock
*
eb
=
extensions
->
ExtensionBlocks
+
i
;
if
(
eb
->
Function
==
GRAPHICS_EXT_FUNC_CODE
&&
eb
->
ByteCount
==
8
&&
eb
->
Bytes
[
3
]
&
1
)
{
int
trans
=
(
unsigned
char
)
eb
->
Bytes
[
6
];
colors
[
trans
]
&=
0xffffff
;
/* set alpha to 0 */
break
;
}
}
}
static
HRESULT
WINAPI
GifFrameDecode_CopyPalette
(
IWICBitmapFrameDecode
*
iface
,
IWICPalette
*
pIPalette
)
{
GifFrameDecode
*
This
=
impl_from_IWICBitmapFrameDecode
(
iface
);
WICColor
colors
[
256
];
ColorMapObject
*
cm
=
This
->
frame
->
ImageDesc
.
ColorMap
;
int
i
,
trans
;
ExtensionBlock
*
eb
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
pIPalette
);
if
(
!
cm
)
cm
=
This
->
parent
->
gif
->
SColorMap
;
...
...
@@ -719,24 +754,7 @@ static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
return
E_FAIL
;
}
for
(
i
=
0
;
i
<
cm
->
ColorCount
;
i
++
)
{
colors
[
i
]
=
0xff000000
|
/* alpha */
cm
->
Colors
[
i
].
Red
<<
16
|
cm
->
Colors
[
i
].
Green
<<
8
|
cm
->
Colors
[
i
].
Blue
;
}
/* look for the transparent color extension */
for
(
i
=
0
;
i
<
This
->
frame
->
Extensions
.
ExtensionBlockCount
;
++
i
)
{
eb
=
This
->
frame
->
Extensions
.
ExtensionBlocks
+
i
;
if
(
eb
->
Function
==
GRAPHICS_EXT_FUNC_CODE
&&
eb
->
ByteCount
==
8
)
{
if
(
eb
->
Bytes
[
3
]
&
1
)
{
trans
=
(
unsigned
char
)
eb
->
Bytes
[
6
];
colors
[
trans
]
&=
0xffffff
;
/* set alpha to 0 */
break
;
}
}
}
copy_palette
(
cm
,
&
This
->
frame
->
Extensions
,
cm
->
ColorCount
,
colors
);
return
IWICPalette_InitializeCustom
(
pIPalette
,
colors
,
cm
->
ColorCount
);
}
...
...
@@ -1170,8 +1188,7 @@ static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalet
GifDecoder
*
This
=
impl_from_IWICBitmapDecoder
(
iface
);
WICColor
colors
[
256
];
ColorMapObject
*
cm
;
int
i
,
trans
,
count
;
ExtensionBlock
*
eb
;
int
count
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
palette
);
...
...
@@ -1187,41 +1204,12 @@ static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalet
return
E_FAIL
;
}
for
(
i
=
0
;
i
<
cm
->
ColorCount
;
i
++
)
{
colors
[
i
]
=
0xff000000
|
/* alpha */
cm
->
Colors
[
i
].
Red
<<
16
|
cm
->
Colors
[
i
].
Green
<<
8
|
cm
->
Colors
[
i
].
Blue
;
}
count
=
cm
->
ColorCount
;
}
else
{
colors
[
0
]
=
0xff000000
;
colors
[
1
]
=
0xffffffff
;
for
(
i
=
2
;
i
<
256
;
i
++
)
colors
[
i
]
=
0xff000000
;
count
=
256
;
}
/* look for the transparent color extension */
for
(
i
=
0
;
i
<
This
->
gif
->
SavedImages
[
This
->
current_frame
].
Extensions
.
ExtensionBlockCount
;
i
++
)
{
eb
=
This
->
gif
->
SavedImages
[
This
->
current_frame
].
Extensions
.
ExtensionBlocks
+
i
;
if
(
eb
->
Function
==
GRAPHICS_EXT_FUNC_CODE
&&
eb
->
ByteCount
==
8
)
{
if
(
eb
->
Bytes
[
3
]
&
1
)
{
trans
=
(
unsigned
char
)
eb
->
Bytes
[
6
];
colors
[
trans
]
&=
0xffffff
;
/* set alpha to 0 */
break
;
}
}
}
copy_palette
(
cm
,
&
This
->
gif
->
SavedImages
[
This
->
current_frame
].
Extensions
,
count
,
colors
);
return
IWICPalette_InitializeCustom
(
palette
,
colors
,
count
);
}
...
...
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