| OLD | NEW |
| 1 | 1 |
| 2 /* pngtrans.c - transforms the data in a row (used by both readers and writers) | 2 /* pngtrans.c - transforms the data in a row (used by both readers and writers) |
| 3 * | 3 * |
| 4 * Last changed in libpng 1.2.36 [May 14, 2009] | 4 * Last changed in libpng 1.2.41 [December 3, 2009] |
| 5 * For conditions of distribution and use, see copyright notice in png.h | |
| 6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson | 5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
| 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 8 * |
| 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 |
| 9 */ | 12 */ |
| 10 | 13 |
| 11 #define PNG_INTERNAL | 14 #define PNG_INTERNAL |
| 15 #define PNG_NO_PEDANTIC_WARNINGS |
| 12 #include "png.h" | 16 #include "png.h" |
| 13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) | 17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 14 | 18 |
| 15 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) | 19 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) |
| 16 /* Turn on BGR-to-RGB mapping */ | 20 /* Turn on BGR-to-RGB mapping */ |
| 17 void PNGAPI | 21 void PNGAPI |
| 18 png_set_bgr(png_structp png_ptr) | 22 png_set_bgr(png_structp png_ptr) |
| 19 { | 23 { |
| 20 png_debug(1, "in png_set_bgr"); | 24 png_debug(1, "in png_set_bgr"); |
| 25 |
| 21 if (png_ptr == NULL) | 26 if (png_ptr == NULL) |
| 22 return; | 27 return; |
| 23 png_ptr->transformations |= PNG_BGR; | 28 png_ptr->transformations |= PNG_BGR; |
| 24 } | 29 } |
| 25 #endif | 30 #endif |
| 26 | 31 |
| 27 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) | 32 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) |
| 28 /* Turn on 16 bit byte swapping */ | 33 /* Turn on 16 bit byte swapping */ |
| 29 void PNGAPI | 34 void PNGAPI |
| 30 png_set_swap(png_structp png_ptr) | 35 png_set_swap(png_structp png_ptr) |
| 31 { | 36 { |
| 32 png_debug(1, "in png_set_swap"); | 37 png_debug(1, "in png_set_swap"); |
| 38 |
| 33 if (png_ptr == NULL) | 39 if (png_ptr == NULL) |
| 34 return; | 40 return; |
| 35 if (png_ptr->bit_depth == 16) | 41 if (png_ptr->bit_depth == 16) |
| 36 png_ptr->transformations |= PNG_SWAP_BYTES; | 42 png_ptr->transformations |= PNG_SWAP_BYTES; |
| 37 } | 43 } |
| 38 #endif | 44 #endif |
| 39 | 45 |
| 40 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) | 46 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) |
| 41 /* Turn on pixel packing */ | 47 /* Turn on pixel packing */ |
| 42 void PNGAPI | 48 void PNGAPI |
| 43 png_set_packing(png_structp png_ptr) | 49 png_set_packing(png_structp png_ptr) |
| 44 { | 50 { |
| 45 png_debug(1, "in png_set_packing"); | 51 png_debug(1, "in png_set_packing"); |
| 52 |
| 46 if (png_ptr == NULL) | 53 if (png_ptr == NULL) |
| 47 return; | 54 return; |
| 48 if (png_ptr->bit_depth < 8) | 55 if (png_ptr->bit_depth < 8) |
| 49 { | 56 { |
| 50 png_ptr->transformations |= PNG_PACK; | 57 png_ptr->transformations |= PNG_PACK; |
| 51 png_ptr->usr_bit_depth = 8; | 58 png_ptr->usr_bit_depth = 8; |
| 52 } | 59 } |
| 53 } | 60 } |
| 54 #endif | 61 #endif |
| 55 | 62 |
| 56 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) | 63 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) |
| 57 /* Turn on packed pixel swapping */ | 64 /* Turn on packed pixel swapping */ |
| 58 void PNGAPI | 65 void PNGAPI |
| 59 png_set_packswap(png_structp png_ptr) | 66 png_set_packswap(png_structp png_ptr) |
| 60 { | 67 { |
| 61 png_debug(1, "in png_set_packswap"); | 68 png_debug(1, "in png_set_packswap"); |
| 69 |
| 62 if (png_ptr == NULL) | 70 if (png_ptr == NULL) |
| 63 return; | 71 return; |
| 64 if (png_ptr->bit_depth < 8) | 72 if (png_ptr->bit_depth < 8) |
| 65 png_ptr->transformations |= PNG_PACKSWAP; | 73 png_ptr->transformations |= PNG_PACKSWAP; |
| 66 } | 74 } |
| 67 #endif | 75 #endif |
| 68 | 76 |
| 69 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) | 77 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) |
| 70 void PNGAPI | 78 void PNGAPI |
| 71 png_set_shift(png_structp png_ptr, png_color_8p true_bits) | 79 png_set_shift(png_structp png_ptr, png_color_8p true_bits) |
| 72 { | 80 { |
| 73 png_debug(1, "in png_set_shift"); | 81 png_debug(1, "in png_set_shift"); |
| 82 |
| 74 if (png_ptr == NULL) | 83 if (png_ptr == NULL) |
| 75 return; | 84 return; |
| 76 png_ptr->transformations |= PNG_SHIFT; | 85 png_ptr->transformations |= PNG_SHIFT; |
| 77 png_ptr->shift = *true_bits; | 86 png_ptr->shift = *true_bits; |
| 78 } | 87 } |
| 79 #endif | 88 #endif |
| 80 | 89 |
| 81 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ | 90 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ |
| 82 defined(PNG_WRITE_INTERLACING_SUPPORTED) | 91 defined(PNG_WRITE_INTERLACING_SUPPORTED) |
| 83 int PNGAPI | 92 int PNGAPI |
| 84 png_set_interlace_handling(png_structp png_ptr) | 93 png_set_interlace_handling(png_structp png_ptr) |
| 85 { | 94 { |
| 86 png_debug(1, "in png_set_interlace handling"); | 95 png_debug(1, "in png_set_interlace handling"); |
| 96 |
| 87 if (png_ptr && png_ptr->interlaced) | 97 if (png_ptr && png_ptr->interlaced) |
| 88 { | 98 { |
| 89 png_ptr->transformations |= PNG_INTERLACE; | 99 png_ptr->transformations |= PNG_INTERLACE; |
| 90 return (7); | 100 return (7); |
| 91 } | 101 } |
| 92 | 102 |
| 93 return (1); | 103 return (1); |
| 94 } | 104 } |
| 95 #endif | 105 #endif |
| 96 | 106 |
| 97 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) | 107 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) |
| 98 /* Add a filler byte on read, or remove a filler or alpha byte on write. | 108 /* Add a filler byte on read, or remove a filler or alpha byte on write. |
| 99 * The filler type has changed in v0.95 to allow future 2-byte fillers | 109 * The filler type has changed in v0.95 to allow future 2-byte fillers |
| 100 * for 48-bit input data, as well as to avoid problems with some compilers | 110 * for 48-bit input data, as well as to avoid problems with some compilers |
| 101 * that don't like bytes as parameters. | 111 * that don't like bytes as parameters. |
| 102 */ | 112 */ |
| 103 void PNGAPI | 113 void PNGAPI |
| 104 png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) | 114 png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) |
| 105 { | 115 { |
| 106 png_debug(1, "in png_set_filler"); | 116 png_debug(1, "in png_set_filler"); |
| 117 |
| 107 if (png_ptr == NULL) | 118 if (png_ptr == NULL) |
| 108 return; | 119 return; |
| 109 png_ptr->transformations |= PNG_FILLER; | 120 png_ptr->transformations |= PNG_FILLER; |
| 121 #ifdef PNG_LEGACY_SUPPORTED |
| 110 png_ptr->filler = (png_byte)filler; | 122 png_ptr->filler = (png_byte)filler; |
| 123 #else |
| 124 png_ptr->filler = (png_uint_16)filler; |
| 125 #endif |
| 111 if (filler_loc == PNG_FILLER_AFTER) | 126 if (filler_loc == PNG_FILLER_AFTER) |
| 112 png_ptr->flags |= PNG_FLAG_FILLER_AFTER; | 127 png_ptr->flags |= PNG_FLAG_FILLER_AFTER; |
| 113 else | 128 else |
| 114 png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; | 129 png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; |
| 115 | 130 |
| 116 /* This should probably go in the "do_read_filler" routine. | 131 /* This should probably go in the "do_read_filler" routine. |
| 117 * I attempted to do that in libpng-1.0.1a but that caused problems | 132 * I attempted to do that in libpng-1.0.1a but that caused problems |
| 118 * so I restored it in libpng-1.0.2a | 133 * so I restored it in libpng-1.0.2a |
| 119 */ | 134 */ |
| 120 | 135 |
| 121 if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) | 136 if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) |
| 122 { | 137 { |
| 123 png_ptr->usr_channels = 4; | 138 png_ptr->usr_channels = 4; |
| 124 } | 139 } |
| 125 | 140 |
| 126 /* Also I added this in libpng-1.0.2a (what happens when we expand | 141 /* Also I added this in libpng-1.0.2a (what happens when we expand |
| 127 * a less-than-8-bit grayscale to GA? */ | 142 * a less-than-8-bit grayscale to GA? */ |
| 128 | 143 |
| 129 if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) | 144 if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) |
| 130 { | 145 { |
| 131 png_ptr->usr_channels = 2; | 146 png_ptr->usr_channels = 2; |
| 132 } | 147 } |
| 133 } | 148 } |
| 134 | 149 |
| 135 #if !defined(PNG_1_0_X) | 150 #ifndef PNG_1_0_X |
| 136 /* Added to libpng-1.2.7 */ | 151 /* Added to libpng-1.2.7 */ |
| 137 void PNGAPI | 152 void PNGAPI |
| 138 png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) | 153 png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) |
| 139 { | 154 { |
| 140 png_debug(1, "in png_set_add_alpha"); | 155 png_debug(1, "in png_set_add_alpha"); |
| 156 |
| 141 if (png_ptr == NULL) | 157 if (png_ptr == NULL) |
| 142 return; | 158 return; |
| 143 png_set_filler(png_ptr, filler, filler_loc); | 159 png_set_filler(png_ptr, filler, filler_loc); |
| 144 png_ptr->transformations |= PNG_ADD_ALPHA; | 160 png_ptr->transformations |= PNG_ADD_ALPHA; |
| 145 } | 161 } |
| 146 #endif | 162 #endif |
| 147 | 163 |
| 148 #endif | 164 #endif |
| 149 | 165 |
| 150 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ | 166 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ |
| 151 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) | 167 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) |
| 152 void PNGAPI | 168 void PNGAPI |
| 153 png_set_swap_alpha(png_structp png_ptr) | 169 png_set_swap_alpha(png_structp png_ptr) |
| 154 { | 170 { |
| 155 png_debug(1, "in png_set_swap_alpha"); | 171 png_debug(1, "in png_set_swap_alpha"); |
| 172 |
| 156 if (png_ptr == NULL) | 173 if (png_ptr == NULL) |
| 157 return; | 174 return; |
| 158 png_ptr->transformations |= PNG_SWAP_ALPHA; | 175 png_ptr->transformations |= PNG_SWAP_ALPHA; |
| 159 } | 176 } |
| 160 #endif | 177 #endif |
| 161 | 178 |
| 162 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ | 179 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ |
| 163 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) | 180 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) |
| 164 void PNGAPI | 181 void PNGAPI |
| 165 png_set_invert_alpha(png_structp png_ptr) | 182 png_set_invert_alpha(png_structp png_ptr) |
| 166 { | 183 { |
| 167 png_debug(1, "in png_set_invert_alpha"); | 184 png_debug(1, "in png_set_invert_alpha"); |
| 185 |
| 168 if (png_ptr == NULL) | 186 if (png_ptr == NULL) |
| 169 return; | 187 return; |
| 170 png_ptr->transformations |= PNG_INVERT_ALPHA; | 188 png_ptr->transformations |= PNG_INVERT_ALPHA; |
| 171 } | 189 } |
| 172 #endif | 190 #endif |
| 173 | 191 |
| 174 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) | 192 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) |
| 175 void PNGAPI | 193 void PNGAPI |
| 176 png_set_invert_mono(png_structp png_ptr) | 194 png_set_invert_mono(png_structp png_ptr) |
| 177 { | 195 { |
| 178 png_debug(1, "in png_set_invert_mono"); | 196 png_debug(1, "in png_set_invert_mono"); |
| 197 |
| 179 if (png_ptr == NULL) | 198 if (png_ptr == NULL) |
| 180 return; | 199 return; |
| 181 png_ptr->transformations |= PNG_INVERT_MONO; | 200 png_ptr->transformations |= PNG_INVERT_MONO; |
| 182 } | 201 } |
| 183 | 202 |
| 184 /* Invert monochrome grayscale data */ | 203 /* Invert monochrome grayscale data */ |
| 185 void /* PRIVATE */ | 204 void /* PRIVATE */ |
| 186 png_do_invert(png_row_infop row_info, png_bytep row) | 205 png_do_invert(png_row_infop row_info, png_bytep row) |
| 187 { | 206 { |
| 188 png_debug(1, "in png_do_invert"); | 207 png_debug(1, "in png_do_invert"); |
| 208 |
| 189 /* This test removed from libpng version 1.0.13 and 1.2.0: | 209 /* This test removed from libpng version 1.0.13 and 1.2.0: |
| 190 * if (row_info->bit_depth == 1 && | 210 * if (row_info->bit_depth == 1 && |
| 191 */ | 211 */ |
| 192 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 212 #ifdef PNG_USELESS_TESTS_SUPPORTED |
| 193 if (row == NULL || row_info == NULL) | 213 if (row == NULL || row_info == NULL) |
| 194 return; | 214 return; |
| 195 #endif | 215 #endif |
| 196 if (row_info->color_type == PNG_COLOR_TYPE_GRAY) | 216 if (row_info->color_type == PNG_COLOR_TYPE_GRAY) |
| 197 { | 217 { |
| 198 png_bytep rp = row; | 218 png_bytep rp = row; |
| 199 png_uint_32 i; | 219 png_uint_32 i; |
| 200 png_uint_32 istop = row_info->rowbytes; | 220 png_uint_32 istop = row_info->rowbytes; |
| 201 | 221 |
| 202 for (i = 0; i < istop; i++) | 222 for (i = 0; i < istop; i++) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 254 } |
| 235 } | 255 } |
| 236 #endif | 256 #endif |
| 237 | 257 |
| 238 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) | 258 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) |
| 239 /* Swaps byte order on 16 bit depth images */ | 259 /* Swaps byte order on 16 bit depth images */ |
| 240 void /* PRIVATE */ | 260 void /* PRIVATE */ |
| 241 png_do_swap(png_row_infop row_info, png_bytep row) | 261 png_do_swap(png_row_infop row_info, png_bytep row) |
| 242 { | 262 { |
| 243 png_debug(1, "in png_do_swap"); | 263 png_debug(1, "in png_do_swap"); |
| 264 |
| 244 if ( | 265 if ( |
| 245 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 266 #ifdef PNG_USELESS_TESTS_SUPPORTED |
| 246 row != NULL && row_info != NULL && | 267 row != NULL && row_info != NULL && |
| 247 #endif | 268 #endif |
| 248 row_info->bit_depth == 16) | 269 row_info->bit_depth == 16) |
| 249 { | 270 { |
| 250 png_bytep rp = row; | 271 png_bytep rp = row; |
| 251 png_uint_32 i; | 272 png_uint_32 i; |
| 252 png_uint_32 istop= row_info->width * row_info->channels; | 273 png_uint_32 istop= row_info->width * row_info->channels; |
| 253 | 274 |
| 254 for (i = 0; i < istop; i++, rp += 2) | 275 for (i = 0; i < istop; i++, rp += 2) |
| 255 { | 276 { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, | 386 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, |
| 366 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, | 387 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, |
| 367 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF | 388 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF |
| 368 }; | 389 }; |
| 369 | 390 |
| 370 /* Swaps pixel packing order within bytes */ | 391 /* Swaps pixel packing order within bytes */ |
| 371 void /* PRIVATE */ | 392 void /* PRIVATE */ |
| 372 png_do_packswap(png_row_infop row_info, png_bytep row) | 393 png_do_packswap(png_row_infop row_info, png_bytep row) |
| 373 { | 394 { |
| 374 png_debug(1, "in png_do_packswap"); | 395 png_debug(1, "in png_do_packswap"); |
| 396 |
| 375 if ( | 397 if ( |
| 376 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 398 #ifdef PNG_USELESS_TESTS_SUPPORTED |
| 377 row != NULL && row_info != NULL && | 399 row != NULL && row_info != NULL && |
| 378 #endif | 400 #endif |
| 379 row_info->bit_depth < 8) | 401 row_info->bit_depth < 8) |
| 380 { | 402 { |
| 381 png_bytep rp, end, table; | 403 png_bytep rp, end, table; |
| 382 | 404 |
| 383 end = row + row_info->rowbytes; | 405 end = row + row_info->rowbytes; |
| 384 | 406 |
| 385 if (row_info->bit_depth == 1) | 407 if (row_info->bit_depth == 1) |
| 386 table = (png_bytep)onebppswaptable; | 408 table = (png_bytep)onebppswaptable; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 397 } | 419 } |
| 398 #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ | 420 #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ |
| 399 | 421 |
| 400 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ | 422 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ |
| 401 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) | 423 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) |
| 402 /* Remove filler or alpha byte(s) */ | 424 /* Remove filler or alpha byte(s) */ |
| 403 void /* PRIVATE */ | 425 void /* PRIVATE */ |
| 404 png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) | 426 png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) |
| 405 { | 427 { |
| 406 png_debug(1, "in png_do_strip_filler"); | 428 png_debug(1, "in png_do_strip_filler"); |
| 407 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 429 |
| 430 #ifdef PNG_USELESS_TESTS_SUPPORTED |
| 408 if (row != NULL && row_info != NULL) | 431 if (row != NULL && row_info != NULL) |
| 409 #endif | 432 #endif |
| 410 { | 433 { |
| 411 png_bytep sp=row; | 434 png_bytep sp=row; |
| 412 png_bytep dp=row; | 435 png_bytep dp=row; |
| 413 png_uint_32 row_width=row_info->width; | 436 png_uint_32 row_width=row_info->width; |
| 414 png_uint_32 i; | 437 png_uint_32 i; |
| 415 | 438 |
| 416 if ((row_info->color_type == PNG_COLOR_TYPE_RGB || | 439 if ((row_info->color_type == PNG_COLOR_TYPE_RGB || |
| 417 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && | 440 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 578 } |
| 556 } | 579 } |
| 557 #endif | 580 #endif |
| 558 | 581 |
| 559 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) | 582 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) |
| 560 /* Swaps red and blue bytes within a pixel */ | 583 /* Swaps red and blue bytes within a pixel */ |
| 561 void /* PRIVATE */ | 584 void /* PRIVATE */ |
| 562 png_do_bgr(png_row_infop row_info, png_bytep row) | 585 png_do_bgr(png_row_infop row_info, png_bytep row) |
| 563 { | 586 { |
| 564 png_debug(1, "in png_do_bgr"); | 587 png_debug(1, "in png_do_bgr"); |
| 588 |
| 565 if ( | 589 if ( |
| 566 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 590 #ifdef PNG_USELESS_TESTS_SUPPORTED |
| 567 row != NULL && row_info != NULL && | 591 row != NULL && row_info != NULL && |
| 568 #endif | 592 #endif |
| 569 (row_info->color_type & PNG_COLOR_MASK_COLOR)) | 593 (row_info->color_type & PNG_COLOR_MASK_COLOR)) |
| 570 { | 594 { |
| 571 png_uint_32 row_width = row_info->width; | 595 png_uint_32 row_width = row_info->width; |
| 572 if (row_info->bit_depth == 8) | 596 if (row_info->bit_depth == 8) |
| 573 { | 597 { |
| 574 if (row_info->color_type == PNG_COLOR_TYPE_RGB) | 598 if (row_info->color_type == PNG_COLOR_TYPE_RGB) |
| 575 { | 599 { |
| 576 png_bytep rp; | 600 png_bytep rp; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 *(rp + 1) = *(rp + 5); | 651 *(rp + 1) = *(rp + 5); |
| 628 *(rp + 5) = save; | 652 *(rp + 5) = save; |
| 629 } | 653 } |
| 630 } | 654 } |
| 631 } | 655 } |
| 632 } | 656 } |
| 633 } | 657 } |
| 634 #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ | 658 #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ |
| 635 | 659 |
| 636 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ | 660 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ |
| 637 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ | 661 defined(PNG_LEGACY_SUPPORTED) || \ |
| 638 defined(PNG_LEGACY_SUPPORTED) | 662 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) |
| 639 void PNGAPI | 663 void PNGAPI |
| 640 png_set_user_transform_info(png_structp png_ptr, png_voidp | 664 png_set_user_transform_info(png_structp png_ptr, png_voidp |
| 641 user_transform_ptr, int user_transform_depth, int user_transform_channels) | 665 user_transform_ptr, int user_transform_depth, int user_transform_channels) |
| 642 { | 666 { |
| 643 png_debug(1, "in png_set_user_transform_info"); | 667 png_debug(1, "in png_set_user_transform_info"); |
| 668 |
| 644 if (png_ptr == NULL) | 669 if (png_ptr == NULL) |
| 645 return; | 670 return; |
| 646 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) | 671 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED |
| 647 png_ptr->user_transform_ptr = user_transform_ptr; | 672 png_ptr->user_transform_ptr = user_transform_ptr; |
| 648 png_ptr->user_transform_depth = (png_byte)user_transform_depth; | 673 png_ptr->user_transform_depth = (png_byte)user_transform_depth; |
| 649 png_ptr->user_transform_channels = (png_byte)user_transform_channels; | 674 png_ptr->user_transform_channels = (png_byte)user_transform_channels; |
| 650 #else | 675 #else |
| 651 if (user_transform_ptr || user_transform_depth || user_transform_channels) | 676 if (user_transform_ptr || user_transform_depth || user_transform_channels) |
| 652 png_warning(png_ptr, | 677 png_warning(png_ptr, |
| 653 "This version of libpng does not support user transform info"); | 678 "This version of libpng does not support user transform info"); |
| 654 #endif | 679 #endif |
| 655 } | 680 } |
| 656 #endif | 681 #endif |
| 657 | 682 |
| 658 /* This function returns a pointer to the user_transform_ptr associated with | 683 /* This function returns a pointer to the user_transform_ptr associated with |
| 659 * the user transform functions. The application should free any memory | 684 * the user transform functions. The application should free any memory |
| 660 * associated with this pointer before png_write_destroy and png_read_destroy | 685 * associated with this pointer before png_write_destroy and png_read_destroy |
| 661 * are called. | 686 * are called. |
| 662 */ | 687 */ |
| 663 png_voidp PNGAPI | 688 png_voidp PNGAPI |
| 664 png_get_user_transform_ptr(png_structp png_ptr) | 689 png_get_user_transform_ptr(png_structp png_ptr) |
| 665 { | 690 { |
| 666 if (png_ptr == NULL) | 691 if (png_ptr == NULL) |
| 667 return (NULL); | 692 return (NULL); |
| 668 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) | 693 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED |
| 669 return ((png_voidp)png_ptr->user_transform_ptr); | 694 return ((png_voidp)png_ptr->user_transform_ptr); |
| 670 #else | 695 #else |
| 671 return (NULL); | 696 return (NULL); |
| 672 #endif | 697 #endif |
| 673 } | 698 } |
| 674 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 699 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |