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
c79b7050
Commit
c79b7050
authored
Sep 23, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Oct 09, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Implement Initialize for the PNG encoder.
parent
60d1be13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
2 deletions
+70
-2
pngformat.c
dlls/windowscodecs/pngformat.c
+70
-2
No files found.
dlls/windowscodecs/pngformat.c
View file @
c79b7050
...
...
@@ -45,7 +45,9 @@ static void *libpng_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
MAKE_FUNCPTR
(
png_create_read_struct
);
MAKE_FUNCPTR
(
png_create_info_struct
);
MAKE_FUNCPTR
(
png_create_write_struct
);
MAKE_FUNCPTR
(
png_destroy_read_struct
);
MAKE_FUNCPTR
(
png_destroy_write_struct
);
MAKE_FUNCPTR
(
png_error
);
MAKE_FUNCPTR
(
png_get_bit_depth
);
MAKE_FUNCPTR
(
png_get_color_type
);
...
...
@@ -61,6 +63,7 @@ MAKE_FUNCPTR(png_set_gray_to_rgb);
MAKE_FUNCPTR
(
png_set_read_fn
);
MAKE_FUNCPTR
(
png_set_strip_16
);
MAKE_FUNCPTR
(
png_set_tRNS_to_alpha
);
MAKE_FUNCPTR
(
png_set_write_fn
);
MAKE_FUNCPTR
(
png_read_end
);
MAKE_FUNCPTR
(
png_read_image
);
MAKE_FUNCPTR
(
png_read_info
);
...
...
@@ -77,7 +80,9 @@ static void *load_libpng(void)
}
LOAD_FUNCPTR
(
png_create_read_struct
);
LOAD_FUNCPTR
(
png_create_info_struct
);
LOAD_FUNCPTR
(
png_create_write_struct
);
LOAD_FUNCPTR
(
png_destroy_read_struct
);
LOAD_FUNCPTR
(
png_destroy_write_struct
);
LOAD_FUNCPTR
(
png_error
);
LOAD_FUNCPTR
(
png_get_bit_depth
);
LOAD_FUNCPTR
(
png_get_color_type
);
...
...
@@ -93,6 +98,7 @@ static void *load_libpng(void)
LOAD_FUNCPTR
(
png_set_read_fn
);
LOAD_FUNCPTR
(
png_set_strip_16
);
LOAD_FUNCPTR
(
png_set_tRNS_to_alpha
);
LOAD_FUNCPTR
(
png_set_write_fn
);
LOAD_FUNCPTR
(
png_read_end
);
LOAD_FUNCPTR
(
png_read_image
);
LOAD_FUNCPTR
(
png_read_info
);
...
...
@@ -662,6 +668,9 @@ HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
typedef
struct
PngEncoder
{
const
IWICBitmapEncoderVtbl
*
lpVtbl
;
LONG
ref
;
IStream
*
stream
;
png_structp
png_ptr
;
png_infop
info_ptr
;
}
PngEncoder
;
static
HRESULT
WINAPI
PngEncoder_QueryInterface
(
IWICBitmapEncoder
*
iface
,
REFIID
iid
,
...
...
@@ -706,17 +715,73 @@ static ULONG WINAPI PngEncoder_Release(IWICBitmapEncoder *iface)
if
(
ref
==
0
)
{
if
(
This
->
png_ptr
)
ppng_destroy_write_struct
(
&
This
->
png_ptr
,
&
This
->
info_ptr
);
if
(
This
->
stream
)
IStream_Release
(
This
->
stream
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
return
ref
;
}
static
void
user_write_data
(
png_structp
png_ptr
,
png_bytep
data
,
png_size_t
length
)
{
PngEncoder
*
This
=
ppng_get_io_ptr
(
png_ptr
);
HRESULT
hr
;
ULONG
byteswritten
;
hr
=
IStream_Write
(
This
->
stream
,
data
,
length
,
&
byteswritten
);
if
(
FAILED
(
hr
)
||
byteswritten
!=
length
)
{
ppng_error
(
png_ptr
,
"failed writing data"
);
}
}
static
void
user_flush
(
png_structp
png_ptr
)
{
}
static
HRESULT
WINAPI
PngEncoder_Initialize
(
IWICBitmapEncoder
*
iface
,
IStream
*
pIStream
,
WICBitmapEncoderCacheOption
cacheOption
)
{
FIXME
(
"(%p,%p,%u): stub
\n
"
,
iface
,
pIStream
,
cacheOption
);
return
E_NOTIMPL
;
PngEncoder
*
This
=
(
PngEncoder
*
)
iface
;
TRACE
(
"(%p,%p,%u)
\n
"
,
iface
,
pIStream
,
cacheOption
);
if
(
This
->
png_ptr
)
return
WINCODEC_ERR_WRONGSTATE
;
/* initialize libpng */
This
->
png_ptr
=
ppng_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
!
This
->
png_ptr
)
return
E_FAIL
;
This
->
info_ptr
=
ppng_create_info_struct
(
This
->
png_ptr
);
if
(
!
This
->
info_ptr
)
{
ppng_destroy_write_struct
(
&
This
->
png_ptr
,
(
png_infopp
)
NULL
);
This
->
png_ptr
=
NULL
;
return
E_FAIL
;
}
IStream_AddRef
(
pIStream
);
This
->
stream
=
pIStream
;
/* set up setjmp/longjmp error handling */
if
(
setjmp
(
png_jmpbuf
(
This
->
png_ptr
)))
{
ppng_destroy_write_struct
(
&
This
->
png_ptr
,
&
This
->
info_ptr
);
This
->
png_ptr
=
NULL
;
IStream_Release
(
This
->
stream
);
This
->
stream
=
NULL
;
return
E_FAIL
;
}
/* set up custom i/o handling */
ppng_set_write_fn
(
This
->
png_ptr
,
This
,
user_write_data
,
user_flush
);
return
S_OK
;
}
static
HRESULT
WINAPI
PngEncoder_GetContainerFormat
(
IWICBitmapEncoder
*
iface
,
...
...
@@ -816,6 +881,9 @@ HRESULT PngEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
This
->
lpVtbl
=
&
PngEncoder_Vtbl
;
This
->
ref
=
1
;
This
->
png_ptr
=
NULL
;
This
->
info_ptr
=
NULL
;
This
->
stream
=
NULL
;
ret
=
IUnknown_QueryInterface
((
IUnknown
*
)
This
,
iid
,
ppv
);
IUnknown_Release
((
IUnknown
*
)
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