The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1 | |
| 2 | /* pngset.c - storage of image information into info struct |
| 3 | * |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 4 | * Last changed in libpng 1.2.38 [July 16, 2009] |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 5 | * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 6 | * (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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 9 | * 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 13 | * 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 21 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 22 | |
| 23 | #if defined(PNG_bKGD_SUPPORTED) |
| 24 | void PNGAPI |
| 25 | png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) |
| 26 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 27 | png_debug1(1, "in %s storage function", "bKGD"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 28 | 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 |
| 38 | void PNGAPI |
| 39 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 43 | png_debug1(1, "in %s storage function", "cHRM"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 44 | if (png_ptr == NULL || info_ptr == NULL) |
| 45 | return; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 46 | |
| 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 67 | #endif /* PNG_FLOATING_POINT_SUPPORTED */ |
| 68 | |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 69 | #ifdef PNG_FIXED_POINT_SUPPORTED |
| 70 | void PNGAPI |
| 71 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 76 | png_debug1(1, "in %s storage function", "cHRM fixed"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 77 | if (png_ptr == NULL || info_ptr == NULL) |
| 78 | return; |
| 79 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 80 | #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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 84 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 85 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 102 | #endif |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 103 | info_ptr->valid |= PNG_INFO_cHRM; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 104 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 105 | } |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 106 | #endif /* PNG_FIXED_POINT_SUPPORTED */ |
| 107 | #endif /* PNG_cHRM_SUPPORTED */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 108 | |
| 109 | #if defined(PNG_gAMA_SUPPORTED) |
| 110 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 111 | void PNGAPI |
| 112 | png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) |
| 113 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 114 | double png_gamma; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 115 | png_debug1(1, "in %s storage function", "gAMA"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 116 | 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 123 | png_gamma=21474.83; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 124 | } |
| 125 | else |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 126 | png_gamma = file_gamma; |
| 127 | info_ptr->gamma = (float)png_gamma; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 128 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 129 | info_ptr->int_gamma = (int)(png_gamma*100000.+.5); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 130 | #endif |
| 131 | info_ptr->valid |= PNG_INFO_gAMA; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 132 | if (png_gamma == 0.0) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 133 | png_warning(png_ptr, "Setting gamma=0"); |
| 134 | } |
| 135 | #endif |
| 136 | void PNGAPI |
| 137 | png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point |
| 138 | int_gamma) |
| 139 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 140 | png_fixed_point png_gamma; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 141 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 142 | png_debug1(1, "in %s storage function", "gAMA"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 143 | if (png_ptr == NULL || info_ptr == NULL) |
| 144 | return; |
| 145 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 146 | if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 147 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 148 | png_warning(png_ptr, "Limiting gamma to 21474.83"); |
| 149 | png_gamma=PNG_UINT_31_MAX; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 150 | } |
| 151 | else |
| 152 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 153 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 160 | } |
| 161 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 162 | info_ptr->gamma = (float)(png_gamma/100000.); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 163 | #endif |
| 164 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 165 | info_ptr->int_gamma = png_gamma; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 166 | #endif |
| 167 | info_ptr->valid |= PNG_INFO_gAMA; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 168 | if (png_gamma == 0) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 169 | png_warning(png_ptr, "Setting gamma=0"); |
| 170 | } |
| 171 | #endif |
| 172 | |
| 173 | #if defined(PNG_hIST_SUPPORTED) |
| 174 | void PNGAPI |
| 175 | png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) |
| 176 | { |
| 177 | int i; |
| 178 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 179 | png_debug1(1, "in %s storage function", "hIST"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 180 | 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 185 | png_warning(png_ptr, |
| 186 | "Invalid palette size, hIST allocation skipped."); |
| 187 | return; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | #ifdef PNG_FREE_ME_SUPPORTED |
| 191 | png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); |
| 192 | #endif |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 193 | /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in |
| 194 | * version 1.2.1 |
| 195 | */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 196 | png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 197 | (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 198 | if (png_ptr->hist == NULL) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 199 | { |
| 200 | png_warning(png_ptr, "Insufficient memory for hIST chunk data."); |
| 201 | return; |
| 202 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 203 | |
| 204 | for (i = 0; i < info_ptr->num_palette; i++) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 205 | png_ptr->hist[i] = hist[i]; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 206 | 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 | |
| 217 | void PNGAPI |
| 218 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 223 | png_debug1(1, "in %s storage function", "IHDR"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 224 | if (png_ptr == NULL || info_ptr == NULL) |
| 225 | return; |
| 226 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 227 | /* Check for width and height valid values */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 228 | 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 247 | /* Check other values */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 248 | if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 249 | bit_depth != 8 && bit_depth != 16) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 250 | png_error(png_ptr, "Invalid bit depth in IHDR"); |
| 251 | |
| 252 | if (color_type < 0 || color_type == 1 || |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 253 | color_type == 5 || color_type > 6) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 254 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 278 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 281 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 282 | if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 283 | (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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 286 | color_type == PNG_COLOR_TYPE_RGB_ALPHA))) |
| 287 | png_error(png_ptr, "Unknown filter method in IHDR"); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 288 | if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 289 | png_warning(png_ptr, "Invalid filter method in IHDR"); |
| 290 | } |
| 291 | #else |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 292 | if (filter_type != PNG_FILTER_TYPE_BASE) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 293 | 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 313 | /* Check for potential overflow */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 314 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 322 | info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | #if defined(PNG_oFFs_SUPPORTED) |
| 326 | void PNGAPI |
| 327 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 330 | png_debug1(1, "in %s storage function", "oFFs"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 331 | 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) |
| 342 | void PNGAPI |
| 343 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 350 | png_debug1(1, "in %s storage function", "pCAL"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 351 | if (png_ptr == NULL || info_ptr == NULL) |
| 352 | return; |
| 353 | |
| 354 | length = png_strlen(purpose) + 1; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 355 | png_debug1(3, "allocating purpose for info (%lu bytes)", |
| 356 | (unsigned long)length); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 357 | info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); |
| 358 | if (info_ptr->pcal_purpose == NULL) |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 359 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 360 | png_warning(png_ptr, "Insufficient memory for pCAL purpose."); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 361 | return; |
| 362 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 363 | png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); |
| 364 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 365 | png_debug(3, "storing X0, X1, type, and nparams in info"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 366 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 372 | png_debug1(3, "allocating units for info (%lu bytes)", |
| 373 | (unsigned long)length); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 374 | info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); |
| 375 | if (info_ptr->pcal_units == NULL) |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 376 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 377 | png_warning(png_ptr, "Insufficient memory for pCAL units."); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 378 | return; |
| 379 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 380 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 385 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 386 | png_warning(png_ptr, "Insufficient memory for pCAL params."); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 387 | return; |
| 388 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 389 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 390 | png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 391 | |
| 392 | for (i = 0; i < nparams; i++) |
| 393 | { |
| 394 | length = png_strlen(params[i]) + 1; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 395 | png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, |
| 396 | (unsigned long)length); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 397 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 399 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 400 | png_warning(png_ptr, "Insufficient memory for pCAL parameter."); |
| 401 | return; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 402 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 403 | png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); |
| 404 | } |
| 405 | |
| 406 | info_ptr->valid |= PNG_INFO_pCAL; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 407 | #ifdef PNG_FREE_ME_SUPPORTED |
| 408 | info_ptr->free_me |= PNG_FREE_PCAL; |
| 409 | #endif |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 410 | } |
| 411 | #endif |
| 412 | |
| 413 | #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) |
| 414 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 415 | void PNGAPI |
| 416 | png_set_sCAL(png_structp png_ptr, png_infop info_ptr, |
| 417 | int unit, double width, double height) |
| 418 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 419 | png_debug1(1, "in %s storage function", "sCAL"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 420 | 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 |
| 431 | void PNGAPI |
| 432 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 437 | png_debug1(1, "in %s storage function", "sCAL"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 438 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 444 | png_debug1(3, "allocating unit for info (%u bytes)", |
| 445 | (unsigned int)length); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 446 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 456 | png_debug1(3, "allocating unit for info (%u bytes)", |
| 457 | (unsigned int)length); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 458 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 462 | info_ptr->scal_s_width = NULL; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 463 | 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) |
| 478 | void PNGAPI |
| 479 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 482 | png_debug1(1, "in %s storage function", "pHYs"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 483 | 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 | |
| 493 | void PNGAPI |
| 494 | png_set_PLTE(png_structp png_ptr, png_infop info_ptr, |
| 495 | png_colorp palette, int num_palette) |
| 496 | { |
| 497 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 498 | png_debug1(1, "in %s storage function", "PLTE"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 499 | if (png_ptr == NULL || info_ptr == NULL) |
| 500 | return; |
| 501 | |
| 502 | if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 503 | { |
| 504 | if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 505 | png_error(png_ptr, "Invalid palette length"); |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 506 | else |
| 507 | { |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 508 | png_warning(png_ptr, "Invalid palette length"); |
| 509 | return; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 510 | } |
| 511 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 512 | |
| 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 523 | * of num_palette entries, in case of an invalid PNG file that has |
| 524 | * too-large sample values. |
| 525 | */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 526 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 530 | png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 531 | 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) |
| 544 | void PNGAPI |
| 545 | png_set_sBIT(png_structp png_ptr, png_infop info_ptr, |
| 546 | png_color_8p sig_bit) |
| 547 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 548 | png_debug1(1, "in %s storage function", "sBIT"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 549 | if (png_ptr == NULL || info_ptr == NULL) |
| 550 | return; |
| 551 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 552 | png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 553 | info_ptr->valid |= PNG_INFO_sBIT; |
| 554 | } |
| 555 | #endif |
| 556 | |
| 557 | #if defined(PNG_sRGB_SUPPORTED) |
| 558 | void PNGAPI |
| 559 | png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) |
| 560 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 561 | png_debug1(1, "in %s storage function", "sRGB"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 562 | 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 | |
| 569 | void PNGAPI |
| 570 | png_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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 585 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 588 | png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 589 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 606 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 615 | #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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 624 | #endif |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 625 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 626 | #if !defined(PNG_NO_CHECK_cHRM) |
| 627 | if (png_check_cHRM_fixed(png_ptr, |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 628 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 630 | #endif |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 631 | { |
| 632 | #ifdef PNG_FIXED_POINT_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 633 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 636 | #endif |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 637 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
| 638 | png_set_cHRM(png_ptr, info_ptr, |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 639 | white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 640 | #endif |
| 641 | } |
| 642 | #endif /* cHRM */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 643 | } |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 644 | #endif /* sRGB */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 645 | |
| 646 | |
| 647 | #if defined(PNG_iCCP_SUPPORTED) |
| 648 | void PNGAPI |
| 649 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 657 | png_debug1(1, "in %s storage function", "iCCP"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 658 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 673 | png_warning(png_ptr, |
| 674 | "Insufficient memory to process iCCP profile."); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 675 | 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) |
| 695 | void PNGAPI |
| 696 | png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 697 | int num_text) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 698 | { |
| 699 | int ret; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 700 | ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 701 | if (ret) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 702 | png_error(png_ptr, "Insufficient memory to store text"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | int /* PRIVATE */ |
| 706 | png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 707 | int num_text) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 708 | { |
| 709 | int i; |
| 710 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 711 | png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ? |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 712 | "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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 731 | (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 732 | if (info_ptr->text == NULL) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 733 | { |
| 734 | png_free(png_ptr, old_text); |
| 735 | return(1); |
| 736 | } |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 737 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 746 | (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 747 | if (info_ptr->text == NULL) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 748 | return(1); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 749 | #ifdef PNG_FREE_ME_SUPPORTED |
| 750 | info_ptr->free_me |= PNG_FREE_TEXT; |
| 751 | #endif |
| 752 | } |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 753 | png_debug1(3, "allocated %d entries for info_ptr->text", |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 754 | info_ptr->max_text); |
| 755 | } |
| 756 | for (i = 0; i < num_text; i++) |
| 757 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 758 | png_size_t text_length, key_len; |
| 759 | png_size_t lang_len, lang_key_len; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 760 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 767 | if (text_ptr[i].compression <= 0) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 768 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 769 | lang_len = 0; |
| 770 | lang_key_len = 0; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 771 | } |
| 772 | else |
| 773 | #ifdef PNG_iTXt_SUPPORTED |
| 774 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 775 | /* 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 784 | } |
| 785 | #else |
| 786 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 787 | png_warning(png_ptr, "iTXt chunk not supported."); |
| 788 | continue; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 789 | } |
| 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 796 | if (text_ptr[i].compression > 0) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 797 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 809 | (png_uint_32) |
| 810 | (key_len + text_length + lang_len + lang_key_len + 4)); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 811 | if (textp->key == NULL) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 812 | return(1); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 813 | png_debug2(2, "Allocated %lu bytes at %x in png_set_text", |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 814 | (png_uint_32) |
| 815 | (key_len + lang_len + lang_key_len + text_length + 4), |
| 816 | (int)textp->key); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 817 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 818 | png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 819 | *(textp->key + key_len) = '\0'; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 820 | #ifdef PNG_iTXt_SUPPORTED |
| 821 | if (text_ptr[i].compression > 0) |
| 822 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 823 | textp->lang = textp->key + key_len + 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 824 | png_memcpy(textp->lang, text_ptr[i].lang, lang_len); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 825 | *(textp->lang + lang_len) = '\0'; |
| 826 | textp->lang_key = textp->lang + lang_len + 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 827 | png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 828 | *(textp->lang_key + lang_key_len) = '\0'; |
| 829 | textp->text = textp->lang_key + lang_key_len + 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 830 | } |
| 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 838 | textp->text = textp->key + key_len + 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 839 | } |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 840 | if (text_length) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 841 | png_memcpy(textp->text, text_ptr[i].text, |
| 842 | (png_size_t)(text_length)); |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 843 | *(textp->text + text_length) = '\0'; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 844 | |
| 845 | #ifdef PNG_iTXt_SUPPORTED |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 846 | if (textp->compression > 0) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 847 | { |
| 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 860 | png_debug1(3, "transferred text chunk %d", info_ptr->num_text); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 861 | } |
| 862 | return(0); |
| 863 | } |
| 864 | #endif |
| 865 | |
| 866 | #if defined(PNG_tIME_SUPPORTED) |
| 867 | void PNGAPI |
| 868 | png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) |
| 869 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 870 | png_debug1(1, "in %s storage function", "tIME"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 871 | if (png_ptr == NULL || info_ptr == NULL || |
| 872 | (png_ptr->mode & PNG_WROTE_tIME)) |
| 873 | return; |
| 874 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 875 | png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time)); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 876 | info_ptr->valid |= PNG_INFO_tIME; |
| 877 | } |
| 878 | #endif |
| 879 | |
| 880 | #if defined(PNG_tRNS_SUPPORTED) |
| 881 | void PNGAPI |
| 882 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 885 | png_debug1(1, "in %s storage function", "tRNS"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 886 | if (png_ptr == NULL || info_ptr == NULL) |
| 887 | return; |
| 888 | |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 889 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 897 | #ifdef PNG_FREE_ME_SUPPORTED |
| 898 | png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); |
| 899 | #endif |
| 900 | |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 901 | /* 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 905 | png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 906 | } |
| 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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 917 | png_warning(png_ptr, |
| 918 | "tRNS chunk has out-of-range samples for bit_depth"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 919 | png_memcpy(&(info_ptr->trans_values), trans_values, |
| 920 | png_sizeof(png_color_16)); |
| 921 | if (num_trans == 0) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 922 | num_trans = 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 923 | } |
| 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) |
| 939 | void PNGAPI |
| 940 | png_set_sPLT(png_structp png_ptr, |
| 941 | png_infop info_ptr, png_sPLT_tp entries, int nentries) |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 942 | /* |
| 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 949 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 950 | png_sPLT_tp np; |
| 951 | int i; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 952 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 953 | if (png_ptr == NULL || info_ptr == NULL) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 954 | return; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 955 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 956 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 964 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 965 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 969 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 970 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 975 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 976 | length = png_strlen(from->name) + 1; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 977 | to->name = (png_charp)png_malloc_warn(png_ptr, length); |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 978 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 986 | (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 987 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1000 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1001 | info_ptr->splt_palettes = np; |
| 1002 | info_ptr->splt_palettes_num += nentries; |
| 1003 | info_ptr->valid |= PNG_INFO_sPLT; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1004 | #ifdef PNG_FREE_ME_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1005 | info_ptr->free_me |= PNG_FREE_SPLT; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1006 | #endif |
| 1007 | } |
| 1008 | #endif /* PNG_sPLT_SUPPORTED */ |
| 1009 | |
| 1010 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) |
| 1011 | void PNGAPI |
| 1012 | png_set_unknown_chunks(png_structp png_ptr, |
| 1013 | png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) |
| 1014 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1015 | png_unknown_chunkp np; |
| 1016 | int i; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1017 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1018 | if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) |
| 1019 | return; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1020 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1021 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1030 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1031 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1035 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1036 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1040 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1041 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1048 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1049 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1065 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1066 | info_ptr->unknown_chunks = np; |
| 1067 | info_ptr->unknown_chunks_num += num_unknowns; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1068 | #ifdef PNG_FREE_ME_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1069 | info_ptr->free_me |= PNG_FREE_UNKN; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1070 | #endif |
| 1071 | } |
| 1072 | void PNGAPI |
| 1073 | png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, |
| 1074 | int chunk, int location) |
| 1075 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1076 | if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1077 | (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) |
| 1085 | void PNGAPI |
| 1086 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1090 | png_debug(1, "in png_permit_empty_plte, DEPRECATED."); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1091 | 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) |
| 1101 | png_uint_32 PNGAPI |
| 1102 | png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) |
| 1103 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1104 | png_debug(1, "in png_permit_mng_features"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1105 | 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) |
| 1114 | void PNGAPI |
| 1115 | png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep |
| 1116 | chunk_list, int num_chunks) |
| 1117 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1118 | 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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1124 | if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1125 | png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1126 | else |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1127 | png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1128 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1129 | if (keep == PNG_HANDLE_CHUNK_ALWAYS) |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1130 | png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1131 | else |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1132 | png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1133 | return; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1134 | } |
| 1135 | if (chunk_list == NULL) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1136 | return; |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1137 | 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1154 | #ifdef PNG_FREE_ME_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1155 | png_ptr->free_me |= PNG_FREE_LIST; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1156 | #endif |
| 1157 | } |
| 1158 | #endif |
| 1159 | |
| 1160 | #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) |
| 1161 | void PNGAPI |
| 1162 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1165 | png_debug(1, "in png_set_read_user_chunk_fn"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1166 | 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) |
| 1174 | void PNGAPI |
| 1175 | png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) |
| 1176 | { |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1177 | png_debug1(1, "in %s storage function", "rows"); |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1178 | |
| 1179 | if (png_ptr == NULL || info_ptr == NULL) |
| 1180 | return; |
| 1181 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1182 | if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1183 | png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); |
| 1184 | info_ptr->row_pointers = row_pointers; |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1185 | if (row_pointers) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1186 | info_ptr->valid |= PNG_INFO_IDAT; |
| 1187 | } |
| 1188 | #endif |
| 1189 | |
| 1190 | #ifdef PNG_WRITE_SUPPORTED |
| 1191 | void PNGAPI |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1192 | png_set_compression_buffer_size(png_structp png_ptr, |
| 1193 | png_uint_32 size) |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1194 | { |
| 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 | |
| 1205 | void PNGAPI |
| 1206 | png_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 Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1215 | /* Function was added to libpng 1.2.0 and should always exist by default */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1216 | void PNGAPI |
| 1217 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1222 | asm_flags = asm_flags; /* Quiet the compiler */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1223 | } |
| 1224 | |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1225 | /* This function was added to libpng 1.2.0 */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1226 | void PNGAPI |
| 1227 | png_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 Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1234 | /* Quiet the compiler */ |
| 1235 | mmx_bitdepth_threshold = mmx_bitdepth_threshold; |
| 1236 | mmx_rowbytes_threshold = mmx_rowbytes_threshold; |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1237 | } |
| 1238 | #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ |
| 1239 | |
| 1240 | #ifdef PNG_SET_USER_LIMITS_SUPPORTED |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1241 | /* This function was added to libpng 1.2.6 */ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1242 | void PNGAPI |
| 1243 | png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, |
| 1244 | png_uint_32 user_height_max) |
| 1245 | { |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 1246 | /* 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 Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1254 | } |
| 1255 | #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ |
| 1256 | |
| 1257 | #endif /* ?PNG_1_0_X */ |
| 1258 | #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |