mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Added png_set_itxt() (work in progress)
This commit is contained in:
69
pngwrite.c
69
pngwrite.c
@@ -1410,6 +1410,75 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
/* end of API added to libpng-1.5.4 */
|
||||
|
||||
#ifdef PNG_WRITE_TEXT_SUPPORTED
|
||||
/* TO DO: synopsis in libpng.3
|
||||
* revise example.c
|
||||
* set up some macros to use instead of 0,1,2,3
|
||||
* test, test, test
|
||||
*/
|
||||
/* API added to libpng-1.6.0 */
|
||||
void PNGAPI
|
||||
png_set_itxt(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const int in_flag, const int in_method, png_const_charp in_key,
|
||||
png_const_charp in_text, png_const_charp in_lang,
|
||||
png_const_charp in_lang_key)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
png_text text_ptr[1];
|
||||
char *key = (png_charp) in_key;
|
||||
char *text = (png_charp) in_text;
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
char *lang = (png_charp) in_lang;
|
||||
char *lang_key = (png_charp) in_lang_key;
|
||||
#endif
|
||||
text_ptr[0].key = key;
|
||||
text_ptr[0].text = text;
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
text_ptr[0].lang = lang;
|
||||
text_ptr[0].lang_key = lang_key;
|
||||
#endif
|
||||
|
||||
/*
|
||||
TO DO: use macros for these.
|
||||
-1: tEXt, none
|
||||
0: zTXt, deflate
|
||||
1: iTXt, none
|
||||
2: iTXt, deflate
|
||||
*/
|
||||
|
||||
if (in_method != 0)
|
||||
png_benign_error(png_ptr,
|
||||
"Only text compression method 0 is supported, using 0.");
|
||||
|
||||
if (in_flag == 0)
|
||||
text_ptr[0].compression = -1;
|
||||
|
||||
else if (in_flag == 1)
|
||||
text_ptr[0].compression = 0;
|
||||
|
||||
else if (in_flag == 2)
|
||||
text_ptr[0].compression = 1;
|
||||
|
||||
else if (in_flag == 3)
|
||||
text_ptr[0].compression = 2;
|
||||
|
||||
else
|
||||
{
|
||||
png_benign_error(png_ptr,
|
||||
"Unrecognized text compression flag, using (compressed iTXt).");
|
||||
text_ptr[0].compression = 2;
|
||||
}
|
||||
|
||||
png_debug(1, "in png_set_itxt");
|
||||
|
||||
/* TO DO: fix compiler warning about discarding qualifier here */
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user