12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* pngset.c - storage of image information into info struct
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * Last changed in libpng 1.6.35 [July 15, 2018]
33 * Copyright (c) 1998-2018 Glenn Randers-Pehrson
34 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
35 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
36 *
37 * This code is released under the libpng license.
38 * For conditions of distribution and use, see the disclaimer
39 * and license in png.h
40 *
41 * The functions here are used during reads to store data from the file
42 * into the info struct, and during writes to store application data
43 * into the info struct for writing into the file. This abstracts the
44 * info struct and allows us to change the structure in the future.
45 */
46
47 #include "pngpriv.h"
48
49 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
50
51 #ifdef PNG_bKGD_SUPPORTED
52 void PNGAPI
53 png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
54 png_const_color_16p background)
55 {
148 double blue_X, double blue_Y, double blue_Z)
149 {
150 png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
151 png_fixed(png_ptr, red_X, "cHRM Red X"),
152 png_fixed(png_ptr, red_Y, "cHRM Red Y"),
153 png_fixed(png_ptr, red_Z, "cHRM Red Z"),
154 png_fixed(png_ptr, green_X, "cHRM Green X"),
155 png_fixed(png_ptr, green_Y, "cHRM Green Y"),
156 png_fixed(png_ptr, green_Z, "cHRM Green Z"),
157 png_fixed(png_ptr, blue_X, "cHRM Blue X"),
158 png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
159 png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
160 }
161 # endif /* FLOATING_POINT */
162
163 #endif /* cHRM */
164
165 #ifdef PNG_eXIf_SUPPORTED
166 void PNGAPI
167 png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
168 const png_bytep eXIf_buf)
169 {
170 png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
171 PNG_UNUSED(info_ptr)
172 PNG_UNUSED(eXIf_buf)
173 }
174
175 void PNGAPI
176 png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
177 const png_uint_32 num_exif, const png_bytep eXIf_buf)
178 {
179 int i;
180
181 png_debug1(1, "in %s storage function", "eXIf");
182
183 if (png_ptr == NULL || info_ptr == NULL)
184 return;
185
186 if (info_ptr->exif)
187 {
188 png_free(png_ptr, info_ptr->exif);
189 info_ptr->exif = NULL;
190 }
191
192 info_ptr->num_exif = num_exif;
193
194 info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
195 info_ptr->num_exif));
196
197 if (info_ptr->exif == NULL)
1410 {
1411 png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
1412
1413 return;
1414 }
1415
1416 if (num_chunks_in <= 0)
1417 {
1418 png_ptr->unknown_default = keep;
1419
1420 /* '0' means just set the flags, so stop here */
1421 if (num_chunks_in == 0)
1422 return;
1423 }
1424
1425 if (num_chunks_in < 0)
1426 {
1427 /* Ignore all unknown chunks and all chunks recognized by
1428 * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
1429 */
1430 static PNG_CONST png_byte chunks_to_ignore[] = {
1431 98, 75, 71, 68, '\0', /* bKGD */
1432 99, 72, 82, 77, '\0', /* cHRM */
1433 101, 88, 73, 102, '\0', /* eXIf */
1434 103, 65, 77, 65, '\0', /* gAMA */
1435 104, 73, 83, 84, '\0', /* hIST */
1436 105, 67, 67, 80, '\0', /* iCCP */
1437 105, 84, 88, 116, '\0', /* iTXt */
1438 111, 70, 70, 115, '\0', /* oFFs */
1439 112, 67, 65, 76, '\0', /* pCAL */
1440 112, 72, 89, 115, '\0', /* pHYs */
1441 115, 66, 73, 84, '\0', /* sBIT */
1442 115, 67, 65, 76, '\0', /* sCAL */
1443 115, 80, 76, 84, '\0', /* sPLT */
1444 115, 84, 69, 82, '\0', /* sTER */
1445 115, 82, 71, 66, '\0', /* sRGB */
1446 116, 69, 88, 116, '\0', /* tEXt */
1447 116, 73, 77, 69, '\0', /* tIME */
1448 122, 84, 88, 116, '\0' /* zTXt */
1449 };
1450
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* pngset.c - storage of image information into info struct
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * Copyright (c) 2018 Cosmin Truta
33 * Copyright (c) 1998-2018 Glenn Randers-Pehrson
34 * Copyright (c) 1996-1997 Andreas Dilger
35 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
36 *
37 * This code is released under the libpng license.
38 * For conditions of distribution and use, see the disclaimer
39 * and license in png.h
40 *
41 * The functions here are used during reads to store data from the file
42 * into the info struct, and during writes to store application data
43 * into the info struct for writing into the file. This abstracts the
44 * info struct and allows us to change the structure in the future.
45 */
46
47 #include "pngpriv.h"
48
49 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
50
51 #ifdef PNG_bKGD_SUPPORTED
52 void PNGAPI
53 png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
54 png_const_color_16p background)
55 {
148 double blue_X, double blue_Y, double blue_Z)
149 {
150 png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
151 png_fixed(png_ptr, red_X, "cHRM Red X"),
152 png_fixed(png_ptr, red_Y, "cHRM Red Y"),
153 png_fixed(png_ptr, red_Z, "cHRM Red Z"),
154 png_fixed(png_ptr, green_X, "cHRM Green X"),
155 png_fixed(png_ptr, green_Y, "cHRM Green Y"),
156 png_fixed(png_ptr, green_Z, "cHRM Green Z"),
157 png_fixed(png_ptr, blue_X, "cHRM Blue X"),
158 png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
159 png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
160 }
161 # endif /* FLOATING_POINT */
162
163 #endif /* cHRM */
164
165 #ifdef PNG_eXIf_SUPPORTED
166 void PNGAPI
167 png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
168 png_bytep eXIf_buf)
169 {
170 png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
171 PNG_UNUSED(info_ptr)
172 PNG_UNUSED(eXIf_buf)
173 }
174
175 void PNGAPI
176 png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
177 png_uint_32 num_exif, png_bytep eXIf_buf)
178 {
179 int i;
180
181 png_debug1(1, "in %s storage function", "eXIf");
182
183 if (png_ptr == NULL || info_ptr == NULL)
184 return;
185
186 if (info_ptr->exif)
187 {
188 png_free(png_ptr, info_ptr->exif);
189 info_ptr->exif = NULL;
190 }
191
192 info_ptr->num_exif = num_exif;
193
194 info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
195 info_ptr->num_exif));
196
197 if (info_ptr->exif == NULL)
1410 {
1411 png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
1412
1413 return;
1414 }
1415
1416 if (num_chunks_in <= 0)
1417 {
1418 png_ptr->unknown_default = keep;
1419
1420 /* '0' means just set the flags, so stop here */
1421 if (num_chunks_in == 0)
1422 return;
1423 }
1424
1425 if (num_chunks_in < 0)
1426 {
1427 /* Ignore all unknown chunks and all chunks recognized by
1428 * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
1429 */
1430 static const png_byte chunks_to_ignore[] = {
1431 98, 75, 71, 68, '\0', /* bKGD */
1432 99, 72, 82, 77, '\0', /* cHRM */
1433 101, 88, 73, 102, '\0', /* eXIf */
1434 103, 65, 77, 65, '\0', /* gAMA */
1435 104, 73, 83, 84, '\0', /* hIST */
1436 105, 67, 67, 80, '\0', /* iCCP */
1437 105, 84, 88, 116, '\0', /* iTXt */
1438 111, 70, 70, 115, '\0', /* oFFs */
1439 112, 67, 65, 76, '\0', /* pCAL */
1440 112, 72, 89, 115, '\0', /* pHYs */
1441 115, 66, 73, 84, '\0', /* sBIT */
1442 115, 67, 65, 76, '\0', /* sCAL */
1443 115, 80, 76, 84, '\0', /* sPLT */
1444 115, 84, 69, 82, '\0', /* sTER */
1445 115, 82, 71, 66, '\0', /* sRGB */
1446 116, 69, 88, 116, '\0', /* tEXt */
1447 116, 73, 77, 69, '\0', /* tIME */
1448 122, 84, 88, 116, '\0' /* zTXt */
1449 };
1450
|