blob: 48e8bbbf02c9a702cd9e88af4f16e81c2dc76d6a [file] [log] [blame]
The Android Open Source Project893912b2009-03-03 19:30:05 -08001
2/* pngset.c - storage of image information into info struct
3 *
Patrick Scotta0bb96c2009-07-22 11:50:02 -04004 * Last changed in libpng 1.2.38 [July 16, 2009]
The Android Open Source Project4215dd12009-03-09 11:52:12 -07005 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
The Android Open Source Project893912b2009-03-03 19:30:05 -08006 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8 *
Patrick Scotta0bb96c2009-07-22 11:50:02 -04009 * This code is released under the libpng license.
10 * For conditions of distribution and use, see the disclaimer
11 * and license in png.h
12 *
The Android Open Source Project893912b2009-03-03 19:30:05 -080013 * The functions here are used during reads to store data from the file
14 * into the info struct, and during writes to store application data
15 * into the info struct for writing into the file. This abstracts the
16 * info struct and allows us to change the structure in the future.
17 */
18
19#define PNG_INTERNAL
20#include "png.h"
The Android Open Source Project893912b2009-03-03 19:30:05 -080021#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
22
23#if defined(PNG_bKGD_SUPPORTED)
24void PNGAPI
25png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
26{
The Android Open Source Project4215dd12009-03-09 11:52:12 -070027 png_debug1(1, "in %s storage function", "bKGD");
The Android Open Source Project893912b2009-03-03 19:30:05 -080028 if (png_ptr == NULL || info_ptr == NULL)
29 return;
30
31 png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));
32 info_ptr->valid |= PNG_INFO_bKGD;
33}
34#endif
35
36#if defined(PNG_cHRM_SUPPORTED)
37#ifdef PNG_FLOATING_POINT_SUPPORTED
38void PNGAPI
39png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
40 double white_x, double white_y, double red_x, double red_y,
41 double green_x, double green_y, double blue_x, double blue_y)
42{
The Android Open Source Project4215dd12009-03-09 11:52:12 -070043 png_debug1(1, "in %s storage function", "cHRM");
The Android Open Source Project893912b2009-03-03 19:30:05 -080044 if (png_ptr == NULL || info_ptr == NULL)
45 return;
The Android Open Source Project893912b2009-03-03 19:30:05 -080046
47 info_ptr->x_white = (float)white_x;
48 info_ptr->y_white = (float)white_y;
49 info_ptr->x_red = (float)red_x;
50 info_ptr->y_red = (float)red_y;
51 info_ptr->x_green = (float)green_x;
52 info_ptr->y_green = (float)green_y;
53 info_ptr->x_blue = (float)blue_x;
54 info_ptr->y_blue = (float)blue_y;
55#ifdef PNG_FIXED_POINT_SUPPORTED
56 info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
57 info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
58 info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5);
59 info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5);
60 info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
61 info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
62 info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5);
63 info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5);
64#endif
65 info_ptr->valid |= PNG_INFO_cHRM;
66}
The Android Open Source Project4215dd12009-03-09 11:52:12 -070067#endif /* PNG_FLOATING_POINT_SUPPORTED */
68
The Android Open Source Project893912b2009-03-03 19:30:05 -080069#ifdef PNG_FIXED_POINT_SUPPORTED
70void PNGAPI
71png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
72 png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
73 png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
74 png_fixed_point blue_x, png_fixed_point blue_y)
75{
The Android Open Source Project4215dd12009-03-09 11:52:12 -070076 png_debug1(1, "in %s storage function", "cHRM fixed");
The Android Open Source Project893912b2009-03-03 19:30:05 -080077 if (png_ptr == NULL || info_ptr == NULL)
78 return;
79
The Android Open Source Project4215dd12009-03-09 11:52:12 -070080#if !defined(PNG_NO_CHECK_cHRM)
81 if (png_check_cHRM_fixed(png_ptr,
82 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
83#endif
The Android Open Source Project893912b2009-03-03 19:30:05 -080084 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -040085 info_ptr->int_x_white = white_x;
86 info_ptr->int_y_white = white_y;
87 info_ptr->int_x_red = red_x;
88 info_ptr->int_y_red = red_y;
89 info_ptr->int_x_green = green_x;
90 info_ptr->int_y_green = green_y;
91 info_ptr->int_x_blue = blue_x;
92 info_ptr->int_y_blue = blue_y;
93#ifdef PNG_FLOATING_POINT_SUPPORTED
94 info_ptr->x_white = (float)(white_x/100000.);
95 info_ptr->y_white = (float)(white_y/100000.);
96 info_ptr->x_red = (float)( red_x/100000.);
97 info_ptr->y_red = (float)( red_y/100000.);
98 info_ptr->x_green = (float)(green_x/100000.);
99 info_ptr->y_green = (float)(green_y/100000.);
100 info_ptr->x_blue = (float)( blue_x/100000.);
101 info_ptr->y_blue = (float)( blue_y/100000.);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800102#endif
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400103 info_ptr->valid |= PNG_INFO_cHRM;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700104 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800105}
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700106#endif /* PNG_FIXED_POINT_SUPPORTED */
107#endif /* PNG_cHRM_SUPPORTED */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800108
109#if defined(PNG_gAMA_SUPPORTED)
110#ifdef PNG_FLOATING_POINT_SUPPORTED
111void PNGAPI
112png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
113{
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400114 double png_gamma;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700115 png_debug1(1, "in %s storage function", "gAMA");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800116 if (png_ptr == NULL || info_ptr == NULL)
117 return;
118
119 /* Check for overflow */
120 if (file_gamma > 21474.83)
121 {
122 png_warning(png_ptr, "Limiting gamma to 21474.83");
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400123 png_gamma=21474.83;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800124 }
125 else
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400126 png_gamma = file_gamma;
127 info_ptr->gamma = (float)png_gamma;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800128#ifdef PNG_FIXED_POINT_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400129 info_ptr->int_gamma = (int)(png_gamma*100000.+.5);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800130#endif
131 info_ptr->valid |= PNG_INFO_gAMA;
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400132 if (png_gamma == 0.0)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800133 png_warning(png_ptr, "Setting gamma=0");
134}
135#endif
136void PNGAPI
137png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
138 int_gamma)
139{
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400140 png_fixed_point png_gamma;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800141
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700142 png_debug1(1, "in %s storage function", "gAMA");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800143 if (png_ptr == NULL || info_ptr == NULL)
144 return;
145
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400146 if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800147 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400148 png_warning(png_ptr, "Limiting gamma to 21474.83");
149 png_gamma=PNG_UINT_31_MAX;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800150 }
151 else
152 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400153 if (int_gamma < 0)
154 {
155 png_warning(png_ptr, "Setting negative gamma to zero");
156 png_gamma = 0;
157 }
158 else
159 png_gamma = int_gamma;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800160 }
161#ifdef PNG_FLOATING_POINT_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400162 info_ptr->gamma = (float)(png_gamma/100000.);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800163#endif
164#ifdef PNG_FIXED_POINT_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400165 info_ptr->int_gamma = png_gamma;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800166#endif
167 info_ptr->valid |= PNG_INFO_gAMA;
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400168 if (png_gamma == 0)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800169 png_warning(png_ptr, "Setting gamma=0");
170}
171#endif
172
173#if defined(PNG_hIST_SUPPORTED)
174void PNGAPI
175png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
176{
177 int i;
178
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700179 png_debug1(1, "in %s storage function", "hIST");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800180 if (png_ptr == NULL || info_ptr == NULL)
181 return;
182 if (info_ptr->num_palette == 0 || info_ptr->num_palette
183 > PNG_MAX_PALETTE_LENGTH)
184 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400185 png_warning(png_ptr,
186 "Invalid palette size, hIST allocation skipped.");
187 return;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800188 }
189
190#ifdef PNG_FREE_ME_SUPPORTED
191 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
192#endif
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400193 /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
194 * version 1.2.1
195 */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800196 png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700197 (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800198 if (png_ptr->hist == NULL)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400199 {
200 png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
201 return;
202 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800203
204 for (i = 0; i < info_ptr->num_palette; i++)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400205 png_ptr->hist[i] = hist[i];
The Android Open Source Project893912b2009-03-03 19:30:05 -0800206 info_ptr->hist = png_ptr->hist;
207 info_ptr->valid |= PNG_INFO_hIST;
208
209#ifdef PNG_FREE_ME_SUPPORTED
210 info_ptr->free_me |= PNG_FREE_HIST;
211#else
212 png_ptr->flags |= PNG_FLAG_FREE_HIST;
213#endif
214}
215#endif
216
217void PNGAPI
218png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
219 png_uint_32 width, png_uint_32 height, int bit_depth,
220 int color_type, int interlace_type, int compression_type,
221 int filter_type)
222{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700223 png_debug1(1, "in %s storage function", "IHDR");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800224 if (png_ptr == NULL || info_ptr == NULL)
225 return;
226
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400227 /* Check for width and height valid values */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800228 if (width == 0 || height == 0)
229 png_error(png_ptr, "Image width or height is zero in IHDR");
230#ifdef PNG_SET_USER_LIMITS_SUPPORTED
231 if (width > png_ptr->user_width_max || height > png_ptr->user_height_max)
232 png_error(png_ptr, "image size exceeds user limits in IHDR");
233#else
234 if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX)
235 png_error(png_ptr, "image size exceeds user limits in IHDR");
236#endif
237 if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX)
238 png_error(png_ptr, "Invalid image size in IHDR");
239 if ( width > (PNG_UINT_32_MAX
240 >> 3) /* 8-byte RGBA pixels */
241 - 64 /* bigrowbuf hack */
242 - 1 /* filter byte */
243 - 7*8 /* rounding of width to multiple of 8 pixels */
244 - 8) /* extra max_pixel_depth pad */
245 png_warning(png_ptr, "Width is too large for libpng to process pixels");
246
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400247 /* Check other values */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800248 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400249 bit_depth != 8 && bit_depth != 16)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800250 png_error(png_ptr, "Invalid bit depth in IHDR");
251
252 if (color_type < 0 || color_type == 1 ||
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400253 color_type == 5 || color_type > 6)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800254 png_error(png_ptr, "Invalid color type in IHDR");
255
256 if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
257 ((color_type == PNG_COLOR_TYPE_RGB ||
258 color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
259 color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
260 png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
261
262 if (interlace_type >= PNG_INTERLACE_LAST)
263 png_error(png_ptr, "Unknown interlace method in IHDR");
264
265 if (compression_type != PNG_COMPRESSION_TYPE_BASE)
266 png_error(png_ptr, "Unknown compression method in IHDR");
267
268#if defined(PNG_MNG_FEATURES_SUPPORTED)
269 /* Accept filter_method 64 (intrapixel differencing) only if
270 * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
271 * 2. Libpng did not read a PNG signature (this filter_method is only
272 * used in PNG datastreams that are embedded in MNG datastreams) and
273 * 3. The application called png_permit_mng_features with a mask that
274 * included PNG_FLAG_MNG_FILTER_64 and
275 * 4. The filter_method is 64 and
276 * 5. The color_type is RGB or RGBA
277 */
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700278 if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
279 png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
280 if (filter_type != PNG_FILTER_TYPE_BASE)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800281 {
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700282 if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400283 (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
284 ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
285 (color_type == PNG_COLOR_TYPE_RGB ||
The Android Open Source Project893912b2009-03-03 19:30:05 -0800286 color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
287 png_error(png_ptr, "Unknown filter method in IHDR");
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700288 if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800289 png_warning(png_ptr, "Invalid filter method in IHDR");
290 }
291#else
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700292 if (filter_type != PNG_FILTER_TYPE_BASE)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800293 png_error(png_ptr, "Unknown filter method in IHDR");
294#endif
295
296 info_ptr->width = width;
297 info_ptr->height = height;
298 info_ptr->bit_depth = (png_byte)bit_depth;
299 info_ptr->color_type =(png_byte) color_type;
300 info_ptr->compression_type = (png_byte)compression_type;
301 info_ptr->filter_type = (png_byte)filter_type;
302 info_ptr->interlace_type = (png_byte)interlace_type;
303 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
304 info_ptr->channels = 1;
305 else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
306 info_ptr->channels = 3;
307 else
308 info_ptr->channels = 1;
309 if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
310 info_ptr->channels++;
311 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
312
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400313 /* Check for potential overflow */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800314 if (width > (PNG_UINT_32_MAX
315 >> 3) /* 8-byte RGBA pixels */
316 - 64 /* bigrowbuf hack */
317 - 1 /* filter byte */
318 - 7*8 /* rounding of width to multiple of 8 pixels */
319 - 8) /* extra max_pixel_depth pad */
320 info_ptr->rowbytes = (png_size_t)0;
321 else
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700322 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800323}
324
325#if defined(PNG_oFFs_SUPPORTED)
326void PNGAPI
327png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
328 png_int_32 offset_x, png_int_32 offset_y, int unit_type)
329{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700330 png_debug1(1, "in %s storage function", "oFFs");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800331 if (png_ptr == NULL || info_ptr == NULL)
332 return;
333
334 info_ptr->x_offset = offset_x;
335 info_ptr->y_offset = offset_y;
336 info_ptr->offset_unit_type = (png_byte)unit_type;
337 info_ptr->valid |= PNG_INFO_oFFs;
338}
339#endif
340
341#if defined(PNG_pCAL_SUPPORTED)
342void PNGAPI
343png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
344 png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
345 png_charp units, png_charpp params)
346{
347 png_uint_32 length;
348 int i;
349
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700350 png_debug1(1, "in %s storage function", "pCAL");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800351 if (png_ptr == NULL || info_ptr == NULL)
352 return;
353
354 length = png_strlen(purpose) + 1;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700355 png_debug1(3, "allocating purpose for info (%lu bytes)",
356 (unsigned long)length);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800357 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
358 if (info_ptr->pcal_purpose == NULL)
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700359 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400360 png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700361 return;
362 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800363 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
364
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700365 png_debug(3, "storing X0, X1, type, and nparams in info");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800366 info_ptr->pcal_X0 = X0;
367 info_ptr->pcal_X1 = X1;
368 info_ptr->pcal_type = (png_byte)type;
369 info_ptr->pcal_nparams = (png_byte)nparams;
370
371 length = png_strlen(units) + 1;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700372 png_debug1(3, "allocating units for info (%lu bytes)",
373 (unsigned long)length);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800374 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
375 if (info_ptr->pcal_units == NULL)
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700376 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400377 png_warning(png_ptr, "Insufficient memory for pCAL units.");
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700378 return;
379 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800380 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
381
382 info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
383 (png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
384 if (info_ptr->pcal_params == NULL)
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700385 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400386 png_warning(png_ptr, "Insufficient memory for pCAL params.");
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700387 return;
388 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800389
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700390 png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800391
392 for (i = 0; i < nparams; i++)
393 {
394 length = png_strlen(params[i]) + 1;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700395 png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
396 (unsigned long)length);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800397 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
398 if (info_ptr->pcal_params[i] == NULL)
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700399 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400400 png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
401 return;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700402 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800403 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
404 }
405
406 info_ptr->valid |= PNG_INFO_pCAL;
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400407#ifdef PNG_FREE_ME_SUPPORTED
408 info_ptr->free_me |= PNG_FREE_PCAL;
409#endif
The Android Open Source Project893912b2009-03-03 19:30:05 -0800410}
411#endif
412
413#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
414#ifdef PNG_FLOATING_POINT_SUPPORTED
415void PNGAPI
416png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
417 int unit, double width, double height)
418{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700419 png_debug1(1, "in %s storage function", "sCAL");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800420 if (png_ptr == NULL || info_ptr == NULL)
421 return;
422
423 info_ptr->scal_unit = (png_byte)unit;
424 info_ptr->scal_pixel_width = width;
425 info_ptr->scal_pixel_height = height;
426
427 info_ptr->valid |= PNG_INFO_sCAL;
428}
429#else
430#ifdef PNG_FIXED_POINT_SUPPORTED
431void PNGAPI
432png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
433 int unit, png_charp swidth, png_charp sheight)
434{
435 png_uint_32 length;
436
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700437 png_debug1(1, "in %s storage function", "sCAL");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800438 if (png_ptr == NULL || info_ptr == NULL)
439 return;
440
441 info_ptr->scal_unit = (png_byte)unit;
442
443 length = png_strlen(swidth) + 1;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700444 png_debug1(3, "allocating unit for info (%u bytes)",
445 (unsigned int)length);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800446 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
447 if (info_ptr->scal_s_width == NULL)
448 {
449 png_warning(png_ptr,
450 "Memory allocation failed while processing sCAL.");
451 return;
452 }
453 png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
454
455 length = png_strlen(sheight) + 1;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700456 png_debug1(3, "allocating unit for info (%u bytes)",
457 (unsigned int)length);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800458 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
459 if (info_ptr->scal_s_height == NULL)
460 {
461 png_free (png_ptr, info_ptr->scal_s_width);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700462 info_ptr->scal_s_width = NULL;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800463 png_warning(png_ptr,
464 "Memory allocation failed while processing sCAL.");
465 return;
466 }
467 png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
468 info_ptr->valid |= PNG_INFO_sCAL;
469#ifdef PNG_FREE_ME_SUPPORTED
470 info_ptr->free_me |= PNG_FREE_SCAL;
471#endif
472}
473#endif
474#endif
475#endif
476
477#if defined(PNG_pHYs_SUPPORTED)
478void PNGAPI
479png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
480 png_uint_32 res_x, png_uint_32 res_y, int unit_type)
481{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700482 png_debug1(1, "in %s storage function", "pHYs");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800483 if (png_ptr == NULL || info_ptr == NULL)
484 return;
485
486 info_ptr->x_pixels_per_unit = res_x;
487 info_ptr->y_pixels_per_unit = res_y;
488 info_ptr->phys_unit_type = (png_byte)unit_type;
489 info_ptr->valid |= PNG_INFO_pHYs;
490}
491#endif
492
493void PNGAPI
494png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
495 png_colorp palette, int num_palette)
496{
497
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700498 png_debug1(1, "in %s storage function", "PLTE");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800499 if (png_ptr == NULL || info_ptr == NULL)
500 return;
501
502 if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400503 {
504 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800505 png_error(png_ptr, "Invalid palette length");
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400506 else
507 {
The Android Open Source Project893912b2009-03-03 19:30:05 -0800508 png_warning(png_ptr, "Invalid palette length");
509 return;
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400510 }
511 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800512
513 /*
514 * It may not actually be necessary to set png_ptr->palette here;
515 * we do it for backward compatibility with the way the png_handle_tRNS
516 * function used to do the allocation.
517 */
518#ifdef PNG_FREE_ME_SUPPORTED
519 png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
520#endif
521
522 /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400523 * of num_palette entries, in case of an invalid PNG file that has
524 * too-large sample values.
525 */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800526 png_ptr->palette = (png_colorp)png_malloc(png_ptr,
527 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
528 png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH *
529 png_sizeof(png_color));
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700530 png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800531 info_ptr->palette = png_ptr->palette;
532 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
533
534#ifdef PNG_FREE_ME_SUPPORTED
535 info_ptr->free_me |= PNG_FREE_PLTE;
536#else
537 png_ptr->flags |= PNG_FLAG_FREE_PLTE;
538#endif
539
540 info_ptr->valid |= PNG_INFO_PLTE;
541}
542
543#if defined(PNG_sBIT_SUPPORTED)
544void PNGAPI
545png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
546 png_color_8p sig_bit)
547{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700548 png_debug1(1, "in %s storage function", "sBIT");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800549 if (png_ptr == NULL || info_ptr == NULL)
550 return;
551
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700552 png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800553 info_ptr->valid |= PNG_INFO_sBIT;
554}
555#endif
556
557#if defined(PNG_sRGB_SUPPORTED)
558void PNGAPI
559png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
560{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700561 png_debug1(1, "in %s storage function", "sRGB");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800562 if (png_ptr == NULL || info_ptr == NULL)
563 return;
564
565 info_ptr->srgb_intent = (png_byte)intent;
566 info_ptr->valid |= PNG_INFO_sRGB;
567}
568
569void PNGAPI
570png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
571 int intent)
572{
573#if defined(PNG_gAMA_SUPPORTED)
574#ifdef PNG_FLOATING_POINT_SUPPORTED
575 float file_gamma;
576#endif
577#ifdef PNG_FIXED_POINT_SUPPORTED
578 png_fixed_point int_file_gamma;
579#endif
580#endif
581#if defined(PNG_cHRM_SUPPORTED)
582#ifdef PNG_FLOATING_POINT_SUPPORTED
583 float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
584#endif
The Android Open Source Project893912b2009-03-03 19:30:05 -0800585 png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
586 int_green_y, int_blue_x, int_blue_y;
587#endif
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700588 png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800589 if (png_ptr == NULL || info_ptr == NULL)
590 return;
591
592 png_set_sRGB(png_ptr, info_ptr, intent);
593
594#if defined(PNG_gAMA_SUPPORTED)
595#ifdef PNG_FLOATING_POINT_SUPPORTED
596 file_gamma = (float).45455;
597 png_set_gAMA(png_ptr, info_ptr, file_gamma);
598#endif
599#ifdef PNG_FIXED_POINT_SUPPORTED
600 int_file_gamma = 45455L;
601 png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
602#endif
603#endif
604
605#if defined(PNG_cHRM_SUPPORTED)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800606 int_white_x = 31270L;
607 int_white_y = 32900L;
608 int_red_x = 64000L;
609 int_red_y = 33000L;
610 int_green_x = 30000L;
611 int_green_y = 60000L;
612 int_blue_x = 15000L;
613 int_blue_y = 6000L;
614
The Android Open Source Project893912b2009-03-03 19:30:05 -0800615#ifdef PNG_FLOATING_POINT_SUPPORTED
616 white_x = (float).3127;
617 white_y = (float).3290;
618 red_x = (float).64;
619 red_y = (float).33;
620 green_x = (float).30;
621 green_y = (float).60;
622 blue_x = (float).15;
623 blue_y = (float).06;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700624#endif
The Android Open Source Project893912b2009-03-03 19:30:05 -0800625
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700626#if !defined(PNG_NO_CHECK_cHRM)
627 if (png_check_cHRM_fixed(png_ptr,
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400628 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
629 int_green_y, int_blue_x, int_blue_y))
The Android Open Source Project893912b2009-03-03 19:30:05 -0800630#endif
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700631 {
632#ifdef PNG_FIXED_POINT_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400633 png_set_cHRM_fixed(png_ptr, info_ptr,
634 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
635 int_green_y, int_blue_x, int_blue_y);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800636#endif
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700637#ifdef PNG_FLOATING_POINT_SUPPORTED
638 png_set_cHRM(png_ptr, info_ptr,
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400639 white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700640#endif
641 }
642#endif /* cHRM */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800643}
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700644#endif /* sRGB */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800645
646
647#if defined(PNG_iCCP_SUPPORTED)
648void PNGAPI
649png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
650 png_charp name, int compression_type,
651 png_charp profile, png_uint_32 proflen)
652{
653 png_charp new_iccp_name;
654 png_charp new_iccp_profile;
655 png_uint_32 length;
656
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700657 png_debug1(1, "in %s storage function", "iCCP");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800658 if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
659 return;
660
661 length = png_strlen(name)+1;
662 new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
663 if (new_iccp_name == NULL)
664 {
665 png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
666 return;
667 }
668 png_memcpy(new_iccp_name, name, length);
669 new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
670 if (new_iccp_profile == NULL)
671 {
672 png_free (png_ptr, new_iccp_name);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700673 png_warning(png_ptr,
674 "Insufficient memory to process iCCP profile.");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800675 return;
676 }
677 png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
678
679 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
680
681 info_ptr->iccp_proflen = proflen;
682 info_ptr->iccp_name = new_iccp_name;
683 info_ptr->iccp_profile = new_iccp_profile;
684 /* Compression is always zero but is here so the API and info structure
685 * does not have to change if we introduce multiple compression types */
686 info_ptr->iccp_compression = (png_byte)compression_type;
687#ifdef PNG_FREE_ME_SUPPORTED
688 info_ptr->free_me |= PNG_FREE_ICCP;
689#endif
690 info_ptr->valid |= PNG_INFO_iCCP;
691}
692#endif
693
694#if defined(PNG_TEXT_SUPPORTED)
695void PNGAPI
696png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400697 int num_text)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800698{
699 int ret;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700700 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800701 if (ret)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400702 png_error(png_ptr, "Insufficient memory to store text");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800703}
704
705int /* PRIVATE */
706png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400707 int num_text)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800708{
709 int i;
710
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700711 png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ?
The Android Open Source Project893912b2009-03-03 19:30:05 -0800712 "text" : (png_const_charp)png_ptr->chunk_name));
713
714 if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
715 return(0);
716
717 /* Make sure we have enough space in the "text" array in info_struct
718 * to hold all of the incoming text_ptr objects.
719 */
720 if (info_ptr->num_text + num_text > info_ptr->max_text)
721 {
722 if (info_ptr->text != NULL)
723 {
724 png_textp old_text;
725 int old_max;
726
727 old_max = info_ptr->max_text;
728 info_ptr->max_text = info_ptr->num_text + num_text + 8;
729 old_text = info_ptr->text;
730 info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700731 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800732 if (info_ptr->text == NULL)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400733 {
734 png_free(png_ptr, old_text);
735 return(1);
736 }
The Android Open Source Project893912b2009-03-03 19:30:05 -0800737 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
738 png_sizeof(png_text)));
739 png_free(png_ptr, old_text);
740 }
741 else
742 {
743 info_ptr->max_text = num_text + 8;
744 info_ptr->num_text = 0;
745 info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700746 (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800747 if (info_ptr->text == NULL)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400748 return(1);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800749#ifdef PNG_FREE_ME_SUPPORTED
750 info_ptr->free_me |= PNG_FREE_TEXT;
751#endif
752 }
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700753 png_debug1(3, "allocated %d entries for info_ptr->text",
The Android Open Source Project893912b2009-03-03 19:30:05 -0800754 info_ptr->max_text);
755 }
756 for (i = 0; i < num_text; i++)
757 {
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700758 png_size_t text_length, key_len;
759 png_size_t lang_len, lang_key_len;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800760 png_textp textp = &(info_ptr->text[info_ptr->num_text]);
761
762 if (text_ptr[i].key == NULL)
763 continue;
764
765 key_len = png_strlen(text_ptr[i].key);
766
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700767 if (text_ptr[i].compression <= 0)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800768 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400769 lang_len = 0;
770 lang_key_len = 0;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800771 }
772 else
773#ifdef PNG_iTXt_SUPPORTED
774 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400775 /* Set iTXt data */
776 if (text_ptr[i].lang != NULL)
777 lang_len = png_strlen(text_ptr[i].lang);
778 else
779 lang_len = 0;
780 if (text_ptr[i].lang_key != NULL)
781 lang_key_len = png_strlen(text_ptr[i].lang_key);
782 else
783 lang_key_len = 0;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800784 }
785#else
786 {
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400787 png_warning(png_ptr, "iTXt chunk not supported.");
788 continue;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800789 }
790#endif
791
792 if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
793 {
794 text_length = 0;
795#ifdef PNG_iTXt_SUPPORTED
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700796 if (text_ptr[i].compression > 0)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800797 textp->compression = PNG_ITXT_COMPRESSION_NONE;
798 else
799#endif
800 textp->compression = PNG_TEXT_COMPRESSION_NONE;
801 }
802 else
803 {
804 text_length = png_strlen(text_ptr[i].text);
805 textp->compression = text_ptr[i].compression;
806 }
807
808 textp->key = (png_charp)png_malloc_warn(png_ptr,
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700809 (png_uint_32)
810 (key_len + text_length + lang_len + lang_key_len + 4));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800811 if (textp->key == NULL)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400812 return(1);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700813 png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400814 (png_uint_32)
815 (key_len + lang_len + lang_key_len + text_length + 4),
816 (int)textp->key);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800817
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400818 png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700819 *(textp->key + key_len) = '\0';
The Android Open Source Project893912b2009-03-03 19:30:05 -0800820#ifdef PNG_iTXt_SUPPORTED
821 if (text_ptr[i].compression > 0)
822 {
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700823 textp->lang = textp->key + key_len + 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800824 png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700825 *(textp->lang + lang_len) = '\0';
826 textp->lang_key = textp->lang + lang_len + 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800827 png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700828 *(textp->lang_key + lang_key_len) = '\0';
829 textp->text = textp->lang_key + lang_key_len + 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800830 }
831 else
832#endif
833 {
834#ifdef PNG_iTXt_SUPPORTED
835 textp->lang=NULL;
836 textp->lang_key=NULL;
837#endif
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700838 textp->text = textp->key + key_len + 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800839 }
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700840 if (text_length)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800841 png_memcpy(textp->text, text_ptr[i].text,
842 (png_size_t)(text_length));
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700843 *(textp->text + text_length) = '\0';
The Android Open Source Project893912b2009-03-03 19:30:05 -0800844
845#ifdef PNG_iTXt_SUPPORTED
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700846 if (textp->compression > 0)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800847 {
848 textp->text_length = 0;
849 textp->itxt_length = text_length;
850 }
851 else
852#endif
853 {
854 textp->text_length = text_length;
855#ifdef PNG_iTXt_SUPPORTED
856 textp->itxt_length = 0;
857#endif
858 }
859 info_ptr->num_text++;
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700860 png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800861 }
862 return(0);
863}
864#endif
865
866#if defined(PNG_tIME_SUPPORTED)
867void PNGAPI
868png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
869{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700870 png_debug1(1, "in %s storage function", "tIME");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800871 if (png_ptr == NULL || info_ptr == NULL ||
872 (png_ptr->mode & PNG_WROTE_tIME))
873 return;
874
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700875 png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
The Android Open Source Project893912b2009-03-03 19:30:05 -0800876 info_ptr->valid |= PNG_INFO_tIME;
877}
878#endif
879
880#if defined(PNG_tRNS_SUPPORTED)
881void PNGAPI
882png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
883 png_bytep trans, int num_trans, png_color_16p trans_values)
884{
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700885 png_debug1(1, "in %s storage function", "tRNS");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800886 if (png_ptr == NULL || info_ptr == NULL)
887 return;
888
The Android Open Source Project893912b2009-03-03 19:30:05 -0800889 if (trans != NULL)
890 {
891 /*
892 * It may not actually be necessary to set png_ptr->trans here;
893 * we do it for backward compatibility with the way the png_handle_tRNS
894 * function used to do the allocation.
895 */
896
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700897#ifdef PNG_FREE_ME_SUPPORTED
898 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
899#endif
900
The Android Open Source Project893912b2009-03-03 19:30:05 -0800901 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
902 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
903 (png_uint_32)PNG_MAX_PALETTE_LENGTH);
904 if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400905 png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
The Android Open Source Project893912b2009-03-03 19:30:05 -0800906 }
907
908 if (trans_values != NULL)
909 {
910 int sample_max = (1 << info_ptr->bit_depth);
911 if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
912 (int)trans_values->gray > sample_max) ||
913 (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
914 ((int)trans_values->red > sample_max ||
915 (int)trans_values->green > sample_max ||
916 (int)trans_values->blue > sample_max)))
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400917 png_warning(png_ptr,
918 "tRNS chunk has out-of-range samples for bit_depth");
The Android Open Source Project893912b2009-03-03 19:30:05 -0800919 png_memcpy(&(info_ptr->trans_values), trans_values,
920 png_sizeof(png_color_16));
921 if (num_trans == 0)
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400922 num_trans = 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800923 }
924
925 info_ptr->num_trans = (png_uint_16)num_trans;
926 if (num_trans != 0)
927 {
928 info_ptr->valid |= PNG_INFO_tRNS;
929#ifdef PNG_FREE_ME_SUPPORTED
930 info_ptr->free_me |= PNG_FREE_TRNS;
931#else
932 png_ptr->flags |= PNG_FLAG_FREE_TRNS;
933#endif
934 }
935}
936#endif
937
938#if defined(PNG_sPLT_SUPPORTED)
939void PNGAPI
940png_set_sPLT(png_structp png_ptr,
941 png_infop info_ptr, png_sPLT_tp entries, int nentries)
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700942/*
943 * entries - array of png_sPLT_t structures
944 * to be added to the list of palettes
945 * in the info structure.
946 * nentries - number of palette structures to be
947 * added.
948 */
The Android Open Source Project893912b2009-03-03 19:30:05 -0800949{
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400950 png_sPLT_tp np;
951 int i;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800952
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400953 if (png_ptr == NULL || info_ptr == NULL)
The Android Open Source Project893912b2009-03-03 19:30:05 -0800954 return;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800955
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400956 np = (png_sPLT_tp)png_malloc_warn(png_ptr,
957 (info_ptr->splt_palettes_num + nentries) *
958 (png_uint_32)png_sizeof(png_sPLT_t));
959 if (np == NULL)
960 {
961 png_warning(png_ptr, "No memory for sPLT palettes.");
962 return;
963 }
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700964
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400965 png_memcpy(np, info_ptr->splt_palettes,
966 info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
967 png_free(png_ptr, info_ptr->splt_palettes);
968 info_ptr->splt_palettes=NULL;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800969
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400970 for (i = 0; i < nentries; i++)
971 {
972 png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
973 png_sPLT_tp from = entries + i;
974 png_uint_32 length;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800975
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400976 length = png_strlen(from->name) + 1;
The Android Open Source Project893912b2009-03-03 19:30:05 -0800977 to->name = (png_charp)png_malloc_warn(png_ptr, length);
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400978 if (to->name == NULL)
979 {
980 png_warning(png_ptr,
981 "Out of memory while processing sPLT chunk");
982 continue;
983 }
984 png_memcpy(to->name, from->name, length);
985 to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700986 (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry)));
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400987 if (to->entries == NULL)
988 {
989 png_warning(png_ptr,
990 "Out of memory while processing sPLT chunk");
991 png_free(png_ptr, to->name);
992 to->name = NULL;
993 continue;
994 }
995 png_memcpy(to->entries, from->entries,
996 from->nentries * png_sizeof(png_sPLT_entry));
997 to->nentries = from->nentries;
998 to->depth = from->depth;
999 }
The Android Open Source Project893912b2009-03-03 19:30:05 -08001000
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001001 info_ptr->splt_palettes = np;
1002 info_ptr->splt_palettes_num += nentries;
1003 info_ptr->valid |= PNG_INFO_sPLT;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001004#ifdef PNG_FREE_ME_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001005 info_ptr->free_me |= PNG_FREE_SPLT;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001006#endif
1007}
1008#endif /* PNG_sPLT_SUPPORTED */
1009
1010#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1011void PNGAPI
1012png_set_unknown_chunks(png_structp png_ptr,
1013 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
1014{
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001015 png_unknown_chunkp np;
1016 int i;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001017
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001018 if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
1019 return;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001020
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001021 np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
1022 (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) *
1023 png_sizeof(png_unknown_chunk)));
1024 if (np == NULL)
1025 {
1026 png_warning(png_ptr,
1027 "Out of memory while processing unknown chunk.");
1028 return;
1029 }
The Android Open Source Project893912b2009-03-03 19:30:05 -08001030
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001031 png_memcpy(np, info_ptr->unknown_chunks,
1032 info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
1033 png_free(png_ptr, info_ptr->unknown_chunks);
1034 info_ptr->unknown_chunks=NULL;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001035
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001036 for (i = 0; i < num_unknowns; i++)
1037 {
1038 png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
1039 png_unknown_chunkp from = unknowns + i;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001040
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001041 png_memcpy((png_charp)to->name,
1042 (png_charp)from->name,
1043 png_sizeof(from->name));
1044 to->name[png_sizeof(to->name)-1] = '\0';
1045 to->size = from->size;
1046 /* Note our location in the read or write sequence */
1047 to->location = (png_byte)(png_ptr->mode & 0xff);
The Android Open Source Project893912b2009-03-03 19:30:05 -08001048
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001049 if (from->size == 0)
1050 to->data=NULL;
1051 else
1052 {
1053 to->data = (png_bytep)png_malloc_warn(png_ptr,
1054 (png_uint_32)from->size);
1055 if (to->data == NULL)
1056 {
1057 png_warning(png_ptr,
1058 "Out of memory while processing unknown chunk.");
1059 to->size = 0;
1060 }
1061 else
1062 png_memcpy(to->data, from->data, from->size);
1063 }
1064 }
The Android Open Source Project893912b2009-03-03 19:30:05 -08001065
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001066 info_ptr->unknown_chunks = np;
1067 info_ptr->unknown_chunks_num += num_unknowns;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001068#ifdef PNG_FREE_ME_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001069 info_ptr->free_me |= PNG_FREE_UNKN;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001070#endif
1071}
1072void PNGAPI
1073png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
1074 int chunk, int location)
1075{
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001076 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
The Android Open Source Project893912b2009-03-03 19:30:05 -08001077 (int)info_ptr->unknown_chunks_num)
1078 info_ptr->unknown_chunks[chunk].location = (png_byte)location;
1079}
1080#endif
1081
1082#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
1083#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
1084 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
1085void PNGAPI
1086png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
1087{
1088 /* This function is deprecated in favor of png_permit_mng_features()
1089 and will be removed from libpng-1.3.0 */
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001090 png_debug(1, "in png_permit_empty_plte, DEPRECATED.");
The Android Open Source Project893912b2009-03-03 19:30:05 -08001091 if (png_ptr == NULL)
1092 return;
1093 png_ptr->mng_features_permitted = (png_byte)
1094 ((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) |
1095 ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
1096}
1097#endif
1098#endif
1099
1100#if defined(PNG_MNG_FEATURES_SUPPORTED)
1101png_uint_32 PNGAPI
1102png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
1103{
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001104 png_debug(1, "in png_permit_mng_features");
The Android Open Source Project893912b2009-03-03 19:30:05 -08001105 if (png_ptr == NULL)
1106 return (png_uint_32)0;
1107 png_ptr->mng_features_permitted =
1108 (png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
1109 return (png_uint_32)png_ptr->mng_features_permitted;
1110}
1111#endif
1112
1113#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1114void PNGAPI
1115png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
1116 chunk_list, int num_chunks)
1117{
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001118 png_bytep new_list, p;
1119 int i, old_num_chunks;
1120 if (png_ptr == NULL)
1121 return;
1122 if (num_chunks == 0)
1123 {
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001124 if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001125 png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001126 else
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001127 png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001128
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001129 if (keep == PNG_HANDLE_CHUNK_ALWAYS)
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001130 png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001131 else
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001132 png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001133 return;
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001134 }
1135 if (chunk_list == NULL)
The Android Open Source Project893912b2009-03-03 19:30:05 -08001136 return;
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001137 old_num_chunks = png_ptr->num_chunk_list;
1138 new_list=(png_bytep)png_malloc(png_ptr,
1139 (png_uint_32)
1140 (5*(num_chunks + old_num_chunks)));
1141 if (png_ptr->chunk_list != NULL)
1142 {
1143 png_memcpy(new_list, png_ptr->chunk_list,
1144 (png_size_t)(5*old_num_chunks));
1145 png_free(png_ptr, png_ptr->chunk_list);
1146 png_ptr->chunk_list=NULL;
1147 }
1148 png_memcpy(new_list + 5*old_num_chunks, chunk_list,
1149 (png_size_t)(5*num_chunks));
1150 for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
1151 *p=(png_byte)keep;
1152 png_ptr->num_chunk_list = old_num_chunks + num_chunks;
1153 png_ptr->chunk_list = new_list;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001154#ifdef PNG_FREE_ME_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001155 png_ptr->free_me |= PNG_FREE_LIST;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001156#endif
1157}
1158#endif
1159
1160#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
1161void PNGAPI
1162png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
1163 png_user_chunk_ptr read_user_chunk_fn)
1164{
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001165 png_debug(1, "in png_set_read_user_chunk_fn");
The Android Open Source Project893912b2009-03-03 19:30:05 -08001166 if (png_ptr == NULL)
1167 return;
1168 png_ptr->read_user_chunk_fn = read_user_chunk_fn;
1169 png_ptr->user_chunk_ptr = user_chunk_ptr;
1170}
1171#endif
1172
1173#if defined(PNG_INFO_IMAGE_SUPPORTED)
1174void PNGAPI
1175png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
1176{
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001177 png_debug1(1, "in %s storage function", "rows");
The Android Open Source Project893912b2009-03-03 19:30:05 -08001178
1179 if (png_ptr == NULL || info_ptr == NULL)
1180 return;
1181
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001182 if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
The Android Open Source Project893912b2009-03-03 19:30:05 -08001183 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
1184 info_ptr->row_pointers = row_pointers;
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001185 if (row_pointers)
The Android Open Source Project893912b2009-03-03 19:30:05 -08001186 info_ptr->valid |= PNG_INFO_IDAT;
1187}
1188#endif
1189
1190#ifdef PNG_WRITE_SUPPORTED
1191void PNGAPI
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001192png_set_compression_buffer_size(png_structp png_ptr,
1193 png_uint_32 size)
The Android Open Source Project893912b2009-03-03 19:30:05 -08001194{
1195 if (png_ptr == NULL)
1196 return;
1197 png_free(png_ptr, png_ptr->zbuf);
1198 png_ptr->zbuf_size = (png_size_t)size;
1199 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
1200 png_ptr->zstream.next_out = png_ptr->zbuf;
1201 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
1202}
1203#endif
1204
1205void PNGAPI
1206png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
1207{
1208 if (png_ptr && info_ptr)
1209 info_ptr->valid &= ~mask;
1210}
1211
1212
1213#ifndef PNG_1_0_X
1214#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001215/* Function was added to libpng 1.2.0 and should always exist by default */
The Android Open Source Project893912b2009-03-03 19:30:05 -08001216void PNGAPI
1217png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
1218{
1219/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
1220 if (png_ptr != NULL)
1221 png_ptr->asm_flags = 0;
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001222 asm_flags = asm_flags; /* Quiet the compiler */
The Android Open Source Project893912b2009-03-03 19:30:05 -08001223}
1224
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001225/* This function was added to libpng 1.2.0 */
The Android Open Source Project893912b2009-03-03 19:30:05 -08001226void PNGAPI
1227png_set_mmx_thresholds (png_structp png_ptr,
1228 png_byte mmx_bitdepth_threshold,
1229 png_uint_32 mmx_rowbytes_threshold)
1230{
1231/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
1232 if (png_ptr == NULL)
1233 return;
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001234 /* Quiet the compiler */
1235 mmx_bitdepth_threshold = mmx_bitdepth_threshold;
1236 mmx_rowbytes_threshold = mmx_rowbytes_threshold;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001237}
1238#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
1239
1240#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001241/* This function was added to libpng 1.2.6 */
The Android Open Source Project893912b2009-03-03 19:30:05 -08001242void PNGAPI
1243png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
1244 png_uint_32 user_height_max)
1245{
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001246 /* Images with dimensions larger than these limits will be
1247 * rejected by png_set_IHDR(). To accept any PNG datastream
1248 * regardless of dimensions, set both limits to 0x7ffffffL.
1249 */
1250 if (png_ptr == NULL)
1251 return;
1252 png_ptr->user_width_max = user_width_max;
1253 png_ptr->user_height_max = user_height_max;
The Android Open Source Project893912b2009-03-03 19:30:05 -08001254}
1255#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
1256
1257#endif /* ?PNG_1_0_X */
1258#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */