15 int open_file_png(char *psz_filename
, hnd_t
*p_handle
, int i_compression
)
17 png_output_t
*h
= NULL
;
18 if( (h
= calloc(1, sizeof(*h
))) == NULL
)
21 if( !strcmp(psz_filename
, "-") )
23 else if( (h
->fh
= fopen(psz_filename
, "wb")) == NULL
)
28 if( (h
->p_png
= png_create_write_struct( PNG_LIBPNG_VER_STRING
, NULL
, NULL
, NULL
)) == NULL
)
33 if( (h
->p_info
= png_create_info_struct(h
->p_png
)) == NULL
)
35 png_destroy_write_struct(&(h
->p_png
), (png_infopp
)NULL
);
39 png_init_io( h
->p_png
, h
->fh
);
41 png_set_compression_level( h
->p_png
, i_compression
);
48 if( h
->fh
!= NULL
&& h
->fh
!= stdout
)
55 int close_file_png( hnd_t handle
)
58 png_output_t
*h
= handle
;
60 png_destroy_write_struct( &(h
->p_png
), &(h
->p_info
) );
62 if ((h
->fh
== NULL
) || (h
->fh
== stdout
))