mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Revised example.c to put text strings in a temporary character array
instead of directly assigning string constants to png_textp members. This avoids compiler warnings when -Wwrite-strings is enabled.
This commit is contained in:
parent
d4247dd398
commit
2c78d4f676
9
ANNOUNCE
9
ANNOUNCE
@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.5.10beta05 - March 11, 2012
|
||||
Libpng 1.5.10beta05 - March 16, 2012
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@ -56,10 +56,13 @@ Version 1.5.10beta04 [March 10, 2012]
|
||||
Fixed CMF optimization of non-IDAT compressed chunks, which was added at
|
||||
libpng-1.5.4. It sometimes produced too small of a window.
|
||||
|
||||
Version 1.5.10beta05 [March 11, 2012]
|
||||
Version 1.5.10beta05 [March 16, 2012]
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Issue a png_benign_error() instead of png_warning() about bad palette index.
|
||||
Fix an off-by-one error in the palette index checking function.
|
||||
Fixed an off-by-one error in the palette index checking function.
|
||||
Revised example.c to put text strings in a temporary character array
|
||||
instead of directly assigning string constants to png_textp members.
|
||||
This avoids compiler warnings when -Wwrite-strings is enabled.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
|
||||
(subscription required; visit
|
||||
|
7
CHANGES
7
CHANGES
@ -3841,10 +3841,13 @@ Version 1.5.10beta04 [March 10, 2012]
|
||||
Fixed CMF optimization of non-IDAT compressed chunks, which was added at
|
||||
libpng-1.5.4. It sometimes produced too small of a window.
|
||||
|
||||
Version 1.5.10beta05 [March 11, 2012]
|
||||
Version 1.5.10beta05 [March 16, 2012]
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Issue a png_benign_error() instead of png_warning() about bad palette index.
|
||||
Fix an off-by-one error in the palette index checking function.
|
||||
Fixed an off-by-one error in the palette index checking function.
|
||||
Revised example.c to put text strings in a temporary character array
|
||||
instead of directly assigning string constants to png_textp members.
|
||||
This avoids compiler warnings when -Wwrite-strings is enabled.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
55
example.c
55
example.c
@ -2,8 +2,8 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
||||
* Maintained 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.5.10 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2012 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*/
|
||||
@ -695,25 +695,38 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||
|
||||
/* Optionally write comments into the image */
|
||||
text_ptr[0].key = "Title";
|
||||
text_ptr[0].text = "Mona Lisa";
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
text_ptr[1].key = "Author";
|
||||
text_ptr[1].text = "Leonardo DaVinci";
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
text_ptr[2].key = "Description";
|
||||
text_ptr[2].text = "<long text>";
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||
{
|
||||
png_text text_ptr[3];
|
||||
|
||||
char key0[]="Title";
|
||||
char text0[]="Mona Lisa";
|
||||
text_ptr[0].key = key0;
|
||||
text_ptr[0].text = text0;
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
|
||||
char key1[]="Author";
|
||||
char text1[]="Leonardo DaVinci";
|
||||
text_ptr[1].key = key1;
|
||||
text_ptr[1].text = text1;
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
|
||||
char key2[]="Description";
|
||||
char text2[]="<long text>";
|
||||
text_ptr[2].key = key2;
|
||||
text_ptr[2].text = text2;
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
|
||||
}
|
||||
|
||||
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user