summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ANNOUNCE1
-rw-r--r--CHANGES1
-rw-r--r--example.c8
-rw-r--r--png.h9
-rw-r--r--pngwrite.c69
-rw-r--r--scripts/symbols.def1
6 files changed, 88 insertions, 1 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index d4640bdd3..8cf9cadb9 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -319,6 +319,7 @@ Version 1.6.0beta18 [March 16, 2012]
this is disabled in which case the simplified API can't be built.)
Version 1.6.0beta19 [March 16, 2012]
+ Added png_set_itxt() (work in progress)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/CHANGES b/CHANGES
index 29ac2b9cf..9e072bece 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4070,6 +4070,7 @@ Version 1.6.0beta18 [March 16, 2012]
this is disabled in which case the simplified API can't be built.)
Version 1.6.0beta19 [March 16, 2012]
+ Added png_set_itxt() (work in progress)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/example.c b/example.c
index ebc43dc60..0549aeb1a 100644
--- a/example.c
+++ b/example.c
@@ -863,6 +863,13 @@ void write_png(char *file_name /* , ... other image information ... */)
*/
png_set_gAMA(png_ptr, info_ptr, gamma);
+#if PNG_LIBPNG_VER >= 1.6.0
+ png_set_itxt(png_ptr, info_ptr, 0, 0, "Title", "Mona Lisa", NULL, NULL);
+ png_set_itxt(png_ptr, info_ptr, 0, 0, "Author", "Leonardo da Vinci", NULL,
+ NULL);
+ png_set_itxt(png_ptr, info_ptr, 3, 0, "Description", "<long text>", NULL,
+ NULL);
+#else
/* Optionally write comments into the image */
{
png_text text_ptr[3];
@@ -896,6 +903,7 @@ void write_png(char *file_name /* , ... other image information ... */)
png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
}
+#endif
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
diff --git a/png.h b/png.h
index 3d394dfa0..f96d01054 100644
--- a/png.h
+++ b/png.h
@@ -2263,6 +2263,13 @@ PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
png_inforp info_ptr, png_const_textp text_ptr, int num_text));
#endif
+#ifdef PNG_WRITE_TEXT_SUPPORTED
+PNG_EXPORT(243, void, 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));
+#endif
+
#ifdef PNG_tIME_SUPPORTED
PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,
png_inforp info_ptr, png_timep *mod_time));
@@ -3081,7 +3088,7 @@ PNG_EXPORT(242, void, png_set_check_for_invalid_index,
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
- PNG_EXPORT_LAST_ORDINAL(242);
+ PNG_EXPORT_LAST_ORDINAL(243);
#endif
#ifdef __cplusplus
diff --git a/pngwrite.c b/pngwrite.c
index 8b3ed0604..45d98e6f7 100644
--- a/pngwrite.c
+++ b/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)
{
diff --git a/scripts/symbols.def b/scripts/symbols.def
index 76e8310fe..3b15a91ec 100644
--- a/scripts/symbols.def
+++ b/scripts/symbols.def
@@ -248,3 +248,4 @@ EXPORTS
png_image_write_to_stdio @240
png_convert_to_rfc1123_buffer @241
png_set_check_for_invalid_index @242
+ png_set_itxt @243