Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
980e6650
Commit
980e6650
authored
Oct 09, 2020
by
Esme Povirk
Committed by
Alexandre Julliard
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Use unix lib to get PNG color contexts.
Signed-off-by:
Esme Povirk
<
esme@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
70ea6485
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
19 deletions
+83
-19
libpng.c
dlls/windowscodecs/libpng.c
+45
-0
pngformat.c
dlls/windowscodecs/pngformat.c
+16
-19
unix_iface.c
dlls/windowscodecs/unix_iface.c
+8
-0
unix_lib.c
dlls/windowscodecs/unix_lib.c
+1
-0
wincodecs_common.h
dlls/windowscodecs/wincodecs_common.h
+6
-0
wincodecs_private.h
dlls/windowscodecs/wincodecs_private.h
+7
-0
No files found.
dlls/windowscodecs/libpng.c
View file @
980e6650
...
...
@@ -54,6 +54,7 @@ MAKE_FUNCPTR(png_error);
MAKE_FUNCPTR
(
png_get_bit_depth
);
MAKE_FUNCPTR
(
png_get_color_type
);
MAKE_FUNCPTR
(
png_get_error_ptr
);
MAKE_FUNCPTR
(
png_get_iCCP
);
MAKE_FUNCPTR
(
png_get_image_height
);
MAKE_FUNCPTR
(
png_get_image_width
);
MAKE_FUNCPTR
(
png_get_io_ptr
);
...
...
@@ -105,6 +106,7 @@ static void *load_libpng(void)
LOAD_FUNCPTR
(
png_get_error_ptr
);
LOAD_FUNCPTR
(
png_get_image_height
);
LOAD_FUNCPTR
(
png_get_image_width
);
LOAD_FUNCPTR
(
png_get_iCCP
);
LOAD_FUNCPTR
(
png_get_io_ptr
);
LOAD_FUNCPTR
(
png_get_pHYs
);
LOAD_FUNCPTR
(
png_get_PLTE
);
...
...
@@ -137,6 +139,8 @@ struct png_decoder
struct
decoder_frame
decoder_frame
;
UINT
stride
;
BYTE
*
image_bits
;
BYTE
*
color_profile
;
DWORD
color_profile_len
;
};
static
inline
struct
png_decoder
*
impl_from_decoder
(
struct
decoder
*
iface
)
...
...
@@ -194,6 +198,10 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
int
i
;
UINT
image_size
;
png_bytep
*
row_pointers
=
NULL
;
png_charp
cp_name
;
png_bytep
cp_profile
;
png_uint_32
cp_len
;
int
cp_compression
;
png_ptr
=
ppng_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
!
png_ptr
)
...
...
@@ -351,6 +359,22 @@ HRESULT CDECL png_decoder_initialize(struct decoder *iface, IStream *stream, str
This
->
decoder_frame
.
dpix
=
This
->
decoder_frame
.
dpiy
=
96
.
0
;
}
ret
=
ppng_get_iCCP
(
png_ptr
,
info_ptr
,
&
cp_name
,
&
cp_compression
,
&
cp_profile
,
&
cp_len
);
if
(
ret
)
{
This
->
decoder_frame
.
num_color_contexts
=
1
;
This
->
color_profile_len
=
cp_len
;
This
->
color_profile
=
malloc
(
cp_len
);
if
(
!
This
->
color_profile
)
{
hr
=
E_OUTOFMEMORY
;
goto
end
;
}
memcpy
(
This
->
color_profile
,
cp_profile
,
cp_len
);
}
else
This
->
decoder_frame
.
num_color_contexts
=
0
;
if
(
color_type
==
PNG_COLOR_TYPE_PALETTE
)
{
ret
=
ppng_get_PLTE
(
png_ptr
,
info_ptr
,
&
png_palette
,
&
num_palette
);
...
...
@@ -437,6 +461,8 @@ end:
{
free
(
This
->
image_bits
);
This
->
image_bits
=
NULL
;
free
(
This
->
color_profile
);
This
->
color_profile
=
NULL
;
}
return
hr
;
}
...
...
@@ -531,11 +557,28 @@ end:
return
hr
;
}
HRESULT
CDECL
png_decoder_get_color_context
(
struct
decoder
*
iface
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
)
{
struct
png_decoder
*
This
=
impl_from_decoder
(
iface
);
*
data
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
This
->
color_profile_len
);
*
datasize
=
This
->
color_profile_len
;
if
(
!*
data
)
return
E_OUTOFMEMORY
;
memcpy
(
*
data
,
This
->
color_profile
,
This
->
color_profile_len
);
return
S_OK
;
}
void
CDECL
png_decoder_destroy
(
struct
decoder
*
iface
)
{
struct
png_decoder
*
This
=
impl_from_decoder
(
iface
);
free
(
This
->
image_bits
);
free
(
This
->
color_profile
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -544,6 +587,7 @@ static const struct decoder_funcs png_decoder_vtable = {
png_decoder_get_frame_info
,
png_decoder_copy_pixels
,
png_decoder_get_metadata_blocks
,
png_decoder_get_color_context
,
png_decoder_destroy
};
...
...
@@ -566,6 +610,7 @@ HRESULT CDECL png_decoder_create(struct decoder_info *info, struct decoder **res
This
->
decoder
.
vtable
=
&
png_decoder_vtable
;
This
->
image_bits
=
NULL
;
This
->
color_profile
=
NULL
;
*
result
=
&
This
->
decoder
;
info
->
container_format
=
GUID_ContainerFormatPng
;
...
...
dlls/windowscodecs/pngformat.c
View file @
980e6650
...
...
@@ -976,37 +976,34 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i
UINT
cCount
,
IWICColorContext
**
ppIColorContexts
,
UINT
*
pcActualCount
)
{
PngDecoder
*
This
=
impl_from_IWICBitmapFrameDecode
(
iface
);
png_charp
name
;
HRESULT
hr
=
S_OK
;
BYTE
*
profile
;
png_uint_32
len
;
int
compression_type
;
HRESULT
hr
;
DWORD
profile_len
;
TRACE
(
"(%p,%u,%p,%p)
\n
"
,
iface
,
cCount
,
ppIColorContexts
,
pcActualCount
);
if
(
!
pcActualCount
)
return
E_INVALIDARG
;
EnterCriticalSection
(
&
This
->
lock
)
;
*
pcActualCount
=
This
->
decoder_frame
.
num_color_contexts
;
if
(
ppng_get_iCCP
(
This
->
png_ptr
,
This
->
info_ptr
,
&
name
,
&
compression_type
,
(
void
*
)
&
profile
,
&
len
)
)
if
(
This
->
decoder_frame
.
num_color_contexts
&&
cCount
&&
ppIColorContexts
)
{
if
(
cCount
&&
ppIColorContexts
)
EnterCriticalSection
(
&
This
->
lock
);
hr
=
decoder_get_color_context
(
This
->
png_decoder
,
0
,
0
,
&
profile
,
&
profile_len
);
LeaveCriticalSection
(
&
This
->
lock
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
IWICColorContext_InitializeFromMemory
(
*
ppIColorContexts
,
profile
,
len
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
This
->
lock
);
return
hr
;
}
hr
=
IWICColorContext_InitializeFromMemory
(
*
ppIColorContexts
,
profile
,
profile_len
);
HeapFree
(
GetProcessHeap
(),
0
,
profile
);
}
*
pcActualCount
=
1
;
}
else
*
pcActualCount
=
0
;
LeaveCriticalSection
(
&
This
->
lock
);
return
S_OK
;
return
hr
;
}
static
HRESULT
WINAPI
PngDecoder_Frame_GetThumbnail
(
IWICBitmapFrameDecode
*
iface
,
...
...
dlls/windowscodecs/unix_iface.c
View file @
980e6650
...
...
@@ -92,6 +92,13 @@ HRESULT CDECL decoder_wrapper_get_metadata_blocks(struct decoder* iface,
return
unix_funcs
->
decoder_get_metadata_blocks
(
This
->
unix_decoder
,
frame
,
count
,
blocks
);
}
HRESULT
CDECL
decoder_wrapper_get_color_context
(
struct
decoder
*
iface
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
)
{
struct
decoder_wrapper
*
This
=
impl_from_decoder
(
iface
);
return
unix_funcs
->
decoder_get_color_context
(
This
->
unix_decoder
,
frame
,
num
,
data
,
datasize
);
}
void
CDECL
decoder_wrapper_destroy
(
struct
decoder
*
iface
)
{
struct
decoder_wrapper
*
This
=
impl_from_decoder
(
iface
);
...
...
@@ -104,6 +111,7 @@ static const struct decoder_funcs decoder_wrapper_vtable = {
decoder_wrapper_get_frame_info
,
decoder_wrapper_copy_pixels
,
decoder_wrapper_get_metadata_blocks
,
decoder_wrapper_get_color_context
,
decoder_wrapper_destroy
};
...
...
dlls/windowscodecs/unix_lib.c
View file @
980e6650
...
...
@@ -71,6 +71,7 @@ static const struct unix_funcs unix_funcs = {
decoder_get_frame_info
,
decoder_copy_pixels
,
decoder_get_metadata_blocks
,
decoder_get_color_context
,
decoder_destroy
};
...
...
dlls/windowscodecs/wincodecs_common.h
View file @
980e6650
...
...
@@ -37,6 +37,12 @@ HRESULT CDECL decoder_get_metadata_blocks(struct decoder *decoder, UINT frame, U
return
decoder
->
vtable
->
get_metadata_blocks
(
decoder
,
frame
,
count
,
blocks
);
}
HRESULT
CDECL
decoder_get_color_context
(
struct
decoder
*
decoder
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
)
{
return
decoder
->
vtable
->
get_color_context
(
decoder
,
frame
,
num
,
data
,
datasize
);
}
void
CDECL
decoder_destroy
(
struct
decoder
*
decoder
)
{
decoder
->
vtable
->
destroy
(
decoder
);
...
...
dlls/windowscodecs/wincodecs_private.h
View file @
980e6650
...
...
@@ -275,6 +275,7 @@ struct decoder_frame
UINT
width
,
height
;
UINT
bpp
;
double
dpix
,
dpiy
;
DWORD
num_color_contexts
;
DWORD
num_colors
;
WICColor
palette
[
256
];
};
...
...
@@ -299,6 +300,8 @@ struct decoder_funcs
UINT
stride
,
UINT
buffersize
,
BYTE
*
buffer
);
HRESULT
(
CDECL
*
get_metadata_blocks
)(
struct
decoder
*
This
,
UINT
frame
,
UINT
*
count
,
struct
decoder_block
**
blocks
);
HRESULT
(
CDECL
*
get_color_context
)(
struct
decoder
*
This
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
);
void
(
CDECL
*
destroy
)(
struct
decoder
*
This
);
};
...
...
@@ -318,6 +321,8 @@ HRESULT CDECL decoder_copy_pixels(struct decoder* This, UINT frame, const WICRec
UINT
stride
,
UINT
buffersize
,
BYTE
*
buffer
);
HRESULT
CDECL
decoder_get_metadata_blocks
(
struct
decoder
*
This
,
UINT
frame
,
UINT
*
count
,
struct
decoder_block
**
blocks
);
HRESULT
CDECL
decoder_get_color_context
(
struct
decoder
*
This
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
);
void
CDECL
decoder_destroy
(
struct
decoder
*
This
);
HRESULT
CDECL
png_decoder_create
(
struct
decoder_info
*
info
,
struct
decoder
**
result
);
...
...
@@ -331,6 +336,8 @@ struct unix_funcs
UINT
stride
,
UINT
buffersize
,
BYTE
*
buffer
);
HRESULT
(
CDECL
*
decoder_get_metadata_blocks
)(
struct
decoder
*
This
,
UINT
frame
,
UINT
*
count
,
struct
decoder_block
**
blocks
);
HRESULT
(
CDECL
*
decoder_get_color_context
)(
struct
decoder
*
This
,
UINT
frame
,
UINT
num
,
BYTE
**
data
,
DWORD
*
datasize
);
void
(
CDECL
*
decoder_destroy
)(
struct
decoder
*
This
);
};
...
...
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