| 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.30 [August 15, 2008] | 4 * Last changed in libpng 1.2.36 [May 14, 2009] |
| 5 * For conditions of distribution and use, see copyright notice in png.h | 5 * For conditions of distribution and use, see copyright notice in png.h |
| 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson | 6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
| 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #define PNG_INTERNAL | 11 #define PNG_INTERNAL |
| 12 #include "png.h" | 12 #include "png.h" |
| 13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) | 13 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 14 | 14 |
| 15 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) | 15 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) |
| 16 /* turn on BGR-to-RGB mapping */ | 16 /* Turn on BGR-to-RGB mapping */ |
| 17 void PNGAPI | 17 void PNGAPI |
| 18 png_set_bgr(png_structp png_ptr) | 18 png_set_bgr(png_structp png_ptr) |
| 19 { | 19 { |
| 20 png_debug(1, "in png_set_bgr"); | 20 png_debug(1, "in png_set_bgr"); |
| 21 if (png_ptr == NULL) return; | 21 if (png_ptr == NULL) |
| 22 return; |
| 22 png_ptr->transformations |= PNG_BGR; | 23 png_ptr->transformations |= PNG_BGR; |
| 23 } | 24 } |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) | 27 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) |
| 27 /* turn on 16 bit byte swapping */ | 28 /* Turn on 16 bit byte swapping */ |
| 28 void PNGAPI | 29 void PNGAPI |
| 29 png_set_swap(png_structp png_ptr) | 30 png_set_swap(png_structp png_ptr) |
| 30 { | 31 { |
| 31 png_debug(1, "in png_set_swap"); | 32 png_debug(1, "in png_set_swap"); |
| 32 if (png_ptr == NULL) return; | 33 if (png_ptr == NULL) |
| 34 return; |
| 33 if (png_ptr->bit_depth == 16) | 35 if (png_ptr->bit_depth == 16) |
| 34 png_ptr->transformations |= PNG_SWAP_BYTES; | 36 png_ptr->transformations |= PNG_SWAP_BYTES; |
| 35 } | 37 } |
| 36 #endif | 38 #endif |
| 37 | 39 |
| 38 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) | 40 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) |
| 39 /* turn on pixel packing */ | 41 /* Turn on pixel packing */ |
| 40 void PNGAPI | 42 void PNGAPI |
| 41 png_set_packing(png_structp png_ptr) | 43 png_set_packing(png_structp png_ptr) |
| 42 { | 44 { |
| 43 png_debug(1, "in png_set_packing"); | 45 png_debug(1, "in png_set_packing"); |
| 44 if (png_ptr == NULL) return; | 46 if (png_ptr == NULL) |
| 47 return; |
| 45 if (png_ptr->bit_depth < 8) | 48 if (png_ptr->bit_depth < 8) |
| 46 { | 49 { |
| 47 png_ptr->transformations |= PNG_PACK; | 50 png_ptr->transformations |= PNG_PACK; |
| 48 png_ptr->usr_bit_depth = 8; | 51 png_ptr->usr_bit_depth = 8; |
| 49 } | 52 } |
| 50 } | 53 } |
| 51 #endif | 54 #endif |
| 52 | 55 |
| 53 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) | 56 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) |
| 54 /* turn on packed pixel swapping */ | 57 /* Turn on packed pixel swapping */ |
| 55 void PNGAPI | 58 void PNGAPI |
| 56 png_set_packswap(png_structp png_ptr) | 59 png_set_packswap(png_structp png_ptr) |
| 57 { | 60 { |
| 58 png_debug(1, "in png_set_packswap"); | 61 png_debug(1, "in png_set_packswap"); |
| 59 if (png_ptr == NULL) return; | 62 if (png_ptr == NULL) |
| 63 return; |
| 60 if (png_ptr->bit_depth < 8) | 64 if (png_ptr->bit_depth < 8) |
| 61 png_ptr->transformations |= PNG_PACKSWAP; | 65 png_ptr->transformations |= PNG_PACKSWAP; |
| 62 } | 66 } |
| 63 #endif | 67 #endif |
| 64 | 68 |
| 65 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) | 69 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) |
| 66 void PNGAPI | 70 void PNGAPI |
| 67 png_set_shift(png_structp png_ptr, png_color_8p true_bits) | 71 png_set_shift(png_structp png_ptr, png_color_8p true_bits) |
| 68 { | 72 { |
| 69 png_debug(1, "in png_set_shift"); | 73 png_debug(1, "in png_set_shift"); |
| 70 if (png_ptr == NULL) return; | 74 if (png_ptr == NULL) |
| 75 return; |
| 71 png_ptr->transformations |= PNG_SHIFT; | 76 png_ptr->transformations |= PNG_SHIFT; |
| 72 png_ptr->shift = *true_bits; | 77 png_ptr->shift = *true_bits; |
| 73 } | 78 } |
| 74 #endif | 79 #endif |
| 75 | 80 |
| 76 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ | 81 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ |
| 77 defined(PNG_WRITE_INTERLACING_SUPPORTED) | 82 defined(PNG_WRITE_INTERLACING_SUPPORTED) |
| 78 int PNGAPI | 83 int PNGAPI |
| 79 png_set_interlace_handling(png_structp png_ptr) | 84 png_set_interlace_handling(png_structp png_ptr) |
| 80 { | 85 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) | 97 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) |
| 93 /* Add a filler byte on read, or remove a filler or alpha byte on write. | 98 /* Add a filler byte on read, or remove a filler or alpha byte on write. |
| 94 * The filler type has changed in v0.95 to allow future 2-byte fillers | 99 * The filler type has changed in v0.95 to allow future 2-byte fillers |
| 95 * for 48-bit input data, as well as to avoid problems with some compilers | 100 * for 48-bit input data, as well as to avoid problems with some compilers |
| 96 * that don't like bytes as parameters. | 101 * that don't like bytes as parameters. |
| 97 */ | 102 */ |
| 98 void PNGAPI | 103 void PNGAPI |
| 99 png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) | 104 png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) |
| 100 { | 105 { |
| 101 png_debug(1, "in png_set_filler"); | 106 png_debug(1, "in png_set_filler"); |
| 102 if (png_ptr == NULL) return; | 107 if (png_ptr == NULL) |
| 108 return; |
| 103 png_ptr->transformations |= PNG_FILLER; | 109 png_ptr->transformations |= PNG_FILLER; |
| 104 png_ptr->filler = (png_byte)filler; | 110 png_ptr->filler = (png_byte)filler; |
| 105 if (filler_loc == PNG_FILLER_AFTER) | 111 if (filler_loc == PNG_FILLER_AFTER) |
| 106 png_ptr->flags |= PNG_FLAG_FILLER_AFTER; | 112 png_ptr->flags |= PNG_FLAG_FILLER_AFTER; |
| 107 else | 113 else |
| 108 png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; | 114 png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; |
| 109 | 115 |
| 110 /* This should probably go in the "do_read_filler" routine. | 116 /* This should probably go in the "do_read_filler" routine. |
| 111 * I attempted to do that in libpng-1.0.1a but that caused problems | 117 * I attempted to do that in libpng-1.0.1a but that caused problems |
| 112 * so I restored it in libpng-1.0.2a | 118 * so I restored it in libpng-1.0.2a |
| (...skipping 12 matching lines...) Expand all Loading... |
| 125 png_ptr->usr_channels = 2; | 131 png_ptr->usr_channels = 2; |
| 126 } | 132 } |
| 127 } | 133 } |
| 128 | 134 |
| 129 #if !defined(PNG_1_0_X) | 135 #if !defined(PNG_1_0_X) |
| 130 /* Added to libpng-1.2.7 */ | 136 /* Added to libpng-1.2.7 */ |
| 131 void PNGAPI | 137 void PNGAPI |
| 132 png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) | 138 png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) |
| 133 { | 139 { |
| 134 png_debug(1, "in png_set_add_alpha"); | 140 png_debug(1, "in png_set_add_alpha"); |
| 135 if (png_ptr == NULL) return; | 141 if (png_ptr == NULL) |
| 142 return; |
| 136 png_set_filler(png_ptr, filler, filler_loc); | 143 png_set_filler(png_ptr, filler, filler_loc); |
| 137 png_ptr->transformations |= PNG_ADD_ALPHA; | 144 png_ptr->transformations |= PNG_ADD_ALPHA; |
| 138 } | 145 } |
| 139 #endif | 146 #endif |
| 140 | 147 |
| 141 #endif | 148 #endif |
| 142 | 149 |
| 143 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ | 150 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ |
| 144 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) | 151 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) |
| 145 void PNGAPI | 152 void PNGAPI |
| 146 png_set_swap_alpha(png_structp png_ptr) | 153 png_set_swap_alpha(png_structp png_ptr) |
| 147 { | 154 { |
| 148 png_debug(1, "in png_set_swap_alpha"); | 155 png_debug(1, "in png_set_swap_alpha"); |
| 149 if (png_ptr == NULL) return; | 156 if (png_ptr == NULL) |
| 157 return; |
| 150 png_ptr->transformations |= PNG_SWAP_ALPHA; | 158 png_ptr->transformations |= PNG_SWAP_ALPHA; |
| 151 } | 159 } |
| 152 #endif | 160 #endif |
| 153 | 161 |
| 154 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ | 162 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ |
| 155 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) | 163 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) |
| 156 void PNGAPI | 164 void PNGAPI |
| 157 png_set_invert_alpha(png_structp png_ptr) | 165 png_set_invert_alpha(png_structp png_ptr) |
| 158 { | 166 { |
| 159 png_debug(1, "in png_set_invert_alpha"); | 167 png_debug(1, "in png_set_invert_alpha"); |
| 160 if (png_ptr == NULL) return; | 168 if (png_ptr == NULL) |
| 169 return; |
| 161 png_ptr->transformations |= PNG_INVERT_ALPHA; | 170 png_ptr->transformations |= PNG_INVERT_ALPHA; |
| 162 } | 171 } |
| 163 #endif | 172 #endif |
| 164 | 173 |
| 165 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) | 174 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) |
| 166 void PNGAPI | 175 void PNGAPI |
| 167 png_set_invert_mono(png_structp png_ptr) | 176 png_set_invert_mono(png_structp png_ptr) |
| 168 { | 177 { |
| 169 png_debug(1, "in png_set_invert_mono"); | 178 png_debug(1, "in png_set_invert_mono"); |
| 170 if (png_ptr == NULL) return; | 179 if (png_ptr == NULL) |
| 180 return; |
| 171 png_ptr->transformations |= PNG_INVERT_MONO; | 181 png_ptr->transformations |= PNG_INVERT_MONO; |
| 172 } | 182 } |
| 173 | 183 |
| 174 /* invert monochrome grayscale data */ | 184 /* Invert monochrome grayscale data */ |
| 175 void /* PRIVATE */ | 185 void /* PRIVATE */ |
| 176 png_do_invert(png_row_infop row_info, png_bytep row) | 186 png_do_invert(png_row_infop row_info, png_bytep row) |
| 177 { | 187 { |
| 178 png_debug(1, "in png_do_invert"); | 188 png_debug(1, "in png_do_invert"); |
| 179 /* This test removed from libpng version 1.0.13 and 1.2.0: | 189 /* This test removed from libpng version 1.0.13 and 1.2.0: |
| 180 * if (row_info->bit_depth == 1 && | 190 * if (row_info->bit_depth == 1 && |
| 181 */ | 191 */ |
| 182 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 192 #if defined(PNG_USELESS_TESTS_SUPPORTED) |
| 183 if (row == NULL || row_info == NULL) | 193 if (row == NULL || row_info == NULL) |
| 184 return; | 194 return; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 { | 229 { |
| 220 *rp = (png_byte)(~(*rp)); | 230 *rp = (png_byte)(~(*rp)); |
| 221 *(rp+1) = (png_byte)(~(*(rp+1))); | 231 *(rp+1) = (png_byte)(~(*(rp+1))); |
| 222 rp+=4; | 232 rp+=4; |
| 223 } | 233 } |
| 224 } | 234 } |
| 225 } | 235 } |
| 226 #endif | 236 #endif |
| 227 | 237 |
| 228 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) | 238 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) |
| 229 /* swaps byte order on 16 bit depth images */ | 239 /* Swaps byte order on 16 bit depth images */ |
| 230 void /* PRIVATE */ | 240 void /* PRIVATE */ |
| 231 png_do_swap(png_row_infop row_info, png_bytep row) | 241 png_do_swap(png_row_infop row_info, png_bytep row) |
| 232 { | 242 { |
| 233 png_debug(1, "in png_do_swap"); | 243 png_debug(1, "in png_do_swap"); |
| 234 if ( | 244 if ( |
| 235 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 245 #if defined(PNG_USELESS_TESTS_SUPPORTED) |
| 236 row != NULL && row_info != NULL && | 246 row != NULL && row_info != NULL && |
| 237 #endif | 247 #endif |
| 238 row_info->bit_depth == 16) | 248 row_info->bit_depth == 16) |
| 239 { | 249 { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, | 360 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, |
| 351 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, | 361 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, |
| 352 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, | 362 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, |
| 353 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, | 363 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, |
| 354 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, | 364 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, |
| 355 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, | 365 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, |
| 356 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, | 366 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, |
| 357 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF | 367 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF |
| 358 }; | 368 }; |
| 359 | 369 |
| 360 /* swaps pixel packing order within bytes */ | 370 /* Swaps pixel packing order within bytes */ |
| 361 void /* PRIVATE */ | 371 void /* PRIVATE */ |
| 362 png_do_packswap(png_row_infop row_info, png_bytep row) | 372 png_do_packswap(png_row_infop row_info, png_bytep row) |
| 363 { | 373 { |
| 364 png_debug(1, "in png_do_packswap"); | 374 png_debug(1, "in png_do_packswap"); |
| 365 if ( | 375 if ( |
| 366 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 376 #if defined(PNG_USELESS_TESTS_SUPPORTED) |
| 367 row != NULL && row_info != NULL && | 377 row != NULL && row_info != NULL && |
| 368 #endif | 378 #endif |
| 369 row_info->bit_depth < 8) | 379 row_info->bit_depth < 8) |
| 370 { | 380 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 382 return; | 392 return; |
| 383 | 393 |
| 384 for (rp = row; rp < end; rp++) | 394 for (rp = row; rp < end; rp++) |
| 385 *rp = table[*rp]; | 395 *rp = table[*rp]; |
| 386 } | 396 } |
| 387 } | 397 } |
| 388 #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ | 398 #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ |
| 389 | 399 |
| 390 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ | 400 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ |
| 391 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) | 401 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) |
| 392 /* remove filler or alpha byte(s) */ | 402 /* Remove filler or alpha byte(s) */ |
| 393 void /* PRIVATE */ | 403 void /* PRIVATE */ |
| 394 png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) | 404 png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) |
| 395 { | 405 { |
| 396 png_debug(1, "in png_do_strip_filler"); | 406 png_debug(1, "in png_do_strip_filler"); |
| 397 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 407 #if defined(PNG_USELESS_TESTS_SUPPORTED) |
| 398 if (row != NULL && row_info != NULL) | 408 if (row != NULL && row_info != NULL) |
| 399 #endif | 409 #endif |
| 400 { | 410 { |
| 401 png_bytep sp=row; | 411 png_bytep sp=row; |
| 402 png_bytep dp=row; | 412 png_bytep dp=row; |
| 403 png_uint_32 row_width=row_info->width; | 413 png_uint_32 row_width=row_info->width; |
| 404 png_uint_32 i; | 414 png_uint_32 i; |
| 405 | 415 |
| 406 if ((row_info->color_type == PNG_COLOR_TYPE_RGB || | 416 if ((row_info->color_type == PNG_COLOR_TYPE_RGB || |
| 407 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && | 417 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && |
| 408 (flags & PNG_FLAG_STRIP_ALPHA))) && | 418 (flags & PNG_FLAG_STRIP_ALPHA))) && |
| 409 row_info->channels == 4) | 419 row_info->channels == 4) |
| 410 { | 420 { |
| 411 if (row_info->bit_depth == 8) | 421 if (row_info->bit_depth == 8) |
| 412 { | 422 { |
| 413 /* This converts from RGBX or RGBA to RGB */ | 423 /* This converts from RGBX or RGBA to RGB */ |
| 414 if (flags & PNG_FLAG_FILLER_AFTER) | 424 if (flags & PNG_FLAG_FILLER_AFTER) |
| 415 { | 425 { |
| 416 dp+=3; sp+=4; | 426 dp+=3; sp+=4; |
| 417 for (i = 1; i < row_width; i++) | 427 for (i = 1; i < row_width; i++) |
| 418 { | 428 { |
| 419 *dp++ = *sp++; | 429 *dp++ = *sp++; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 550 } |
| 541 row_info->channels = 1; | 551 row_info->channels = 1; |
| 542 } | 552 } |
| 543 if (flags & PNG_FLAG_STRIP_ALPHA) | 553 if (flags & PNG_FLAG_STRIP_ALPHA) |
| 544 row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; | 554 row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; |
| 545 } | 555 } |
| 546 } | 556 } |
| 547 #endif | 557 #endif |
| 548 | 558 |
| 549 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) | 559 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) |
| 550 /* swaps red and blue bytes within a pixel */ | 560 /* Swaps red and blue bytes within a pixel */ |
| 551 void /* PRIVATE */ | 561 void /* PRIVATE */ |
| 552 png_do_bgr(png_row_infop row_info, png_bytep row) | 562 png_do_bgr(png_row_infop row_info, png_bytep row) |
| 553 { | 563 { |
| 554 png_debug(1, "in png_do_bgr"); | 564 png_debug(1, "in png_do_bgr"); |
| 555 if ( | 565 if ( |
| 556 #if defined(PNG_USELESS_TESTS_SUPPORTED) | 566 #if defined(PNG_USELESS_TESTS_SUPPORTED) |
| 557 row != NULL && row_info != NULL && | 567 row != NULL && row_info != NULL && |
| 558 #endif | 568 #endif |
| 559 (row_info->color_type & PNG_COLOR_MASK_COLOR)) | 569 (row_info->color_type & PNG_COLOR_MASK_COLOR)) |
| 560 { | 570 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ | 634 #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ |
| 625 | 635 |
| 626 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ | 636 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ |
| 627 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ | 637 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ |
| 628 defined(PNG_LEGACY_SUPPORTED) | 638 defined(PNG_LEGACY_SUPPORTED) |
| 629 void PNGAPI | 639 void PNGAPI |
| 630 png_set_user_transform_info(png_structp png_ptr, png_voidp | 640 png_set_user_transform_info(png_structp png_ptr, png_voidp |
| 631 user_transform_ptr, int user_transform_depth, int user_transform_channels) | 641 user_transform_ptr, int user_transform_depth, int user_transform_channels) |
| 632 { | 642 { |
| 633 png_debug(1, "in png_set_user_transform_info"); | 643 png_debug(1, "in png_set_user_transform_info"); |
| 634 if (png_ptr == NULL) return; | 644 if (png_ptr == NULL) |
| 645 return; |
| 635 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) | 646 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) |
| 636 png_ptr->user_transform_ptr = user_transform_ptr; | 647 png_ptr->user_transform_ptr = user_transform_ptr; |
| 637 png_ptr->user_transform_depth = (png_byte)user_transform_depth; | 648 png_ptr->user_transform_depth = (png_byte)user_transform_depth; |
| 638 png_ptr->user_transform_channels = (png_byte)user_transform_channels; | 649 png_ptr->user_transform_channels = (png_byte)user_transform_channels; |
| 639 #else | 650 #else |
| 640 if (user_transform_ptr || user_transform_depth || user_transform_channels) | 651 if (user_transform_ptr || user_transform_depth || user_transform_channels) |
| 641 png_warning(png_ptr, | 652 png_warning(png_ptr, |
| 642 "This version of libpng does not support user transform info"); | 653 "This version of libpng does not support user transform info"); |
| 643 #endif | 654 #endif |
| 644 } | 655 } |
| 645 #endif | 656 #endif |
| 646 | 657 |
| 647 /* This function returns a pointer to the user_transform_ptr associated with | 658 /* This function returns a pointer to the user_transform_ptr associated with |
| 648 * the user transform functions. The application should free any memory | 659 * the user transform functions. The application should free any memory |
| 649 * associated with this pointer before png_write_destroy and png_read_destroy | 660 * associated with this pointer before png_write_destroy and png_read_destroy |
| 650 * are called. | 661 * are called. |
| 651 */ | 662 */ |
| 652 png_voidp PNGAPI | 663 png_voidp PNGAPI |
| 653 png_get_user_transform_ptr(png_structp png_ptr) | 664 png_get_user_transform_ptr(png_structp png_ptr) |
| 654 { | 665 { |
| 655 if (png_ptr == NULL) return (NULL); | 666 if (png_ptr == NULL) |
| 667 return (NULL); |
| 656 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) | 668 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) |
| 657 return ((png_voidp)png_ptr->user_transform_ptr); | 669 return ((png_voidp)png_ptr->user_transform_ptr); |
| 658 #else | 670 #else |
| 659 return (NULL); | 671 return (NULL); |
| 660 #endif | 672 #endif |
| 661 } | 673 } |
| 662 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 674 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |