3187 #ifdef PNG_READ_GAMMA_SUPPORTED 3194 int gamma_shift = png_ptr->gamma_shift;
3200 png_uint_32 row_width = row_info->
width;
3216 for (i = 0; i < row_width; i++)
3218 if ((png_uint_16)((*sp >> shift) & 0x01)
3219 == png_ptr->trans_color.gray)
3221 unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
3222 tmp |= png_ptr->background.gray << shift;
3223 *sp = (png_byte)(tmp & 0xff);
3240 #ifdef PNG_READ_GAMMA_SUPPORTED 3241 if (gamma_table != NULL)
3245 for (i = 0; i < row_width; i++)
3247 if ((png_uint_16)((*sp >> shift) & 0x03)
3248 == png_ptr->trans_color.gray)
3250 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3251 tmp |= png_ptr->background.gray << shift;
3252 *sp = (png_byte)(tmp & 0xff);
3257 unsigned int p = (*sp >> shift) & 0x03;
3258 unsigned int g = (gamma_table [p | (p << 2) |
3259 (p << 4) | (p << 6)] >> 6) & 0x03;
3260 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3262 *sp = (png_byte)(tmp & 0xff);
3281 for (i = 0; i < row_width; i++)
3283 if ((png_uint_16)((*sp >> shift) & 0x03)
3284 == png_ptr->trans_color.gray)
3286 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3287 tmp |= png_ptr->background.gray << shift;
3288 *sp = (png_byte)(tmp & 0xff);
3306 #ifdef PNG_READ_GAMMA_SUPPORTED 3307 if (gamma_table != NULL)
3311 for (i = 0; i < row_width; i++)
3313 if ((png_uint_16)((*sp >> shift) & 0x0f)
3314 == png_ptr->trans_color.gray)
3316 unsigned int tmp = *sp & (0xf0f >> (4 - shift));
3317 tmp |= png_ptr->background.gray << shift;
3318 *sp = (png_byte)(tmp & 0xff);
3323 unsigned int p = (*sp >> shift) & 0x0f;
3324 unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
3326 unsigned int tmp = *sp & (0xf0f >> (4 - shift));
3328 *sp = (png_byte)(tmp & 0xff);
3347 for (i = 0; i < row_width; i++)
3349 if ((png_uint_16)((*sp >> shift) & 0x0f)
3350 == png_ptr->trans_color.gray)
3352 unsigned int tmp = *sp & (0xf0f >> (4 - shift));
3353 tmp |= png_ptr->background.gray << shift;
3354 *sp = (png_byte)(tmp & 0xff);
3372 #ifdef PNG_READ_GAMMA_SUPPORTED 3373 if (gamma_table != NULL)
3376 for (i = 0; i < row_width; i++, sp++)
3378 if (*sp == png_ptr->trans_color.gray)
3379 *sp = (png_byte)png_ptr->background.gray;
3382 *sp = gamma_table[*sp];
3389 for (i = 0; i < row_width; i++, sp++)
3391 if (*sp == png_ptr->trans_color.gray)
3392 *sp = (png_byte)png_ptr->background.gray;
3400 #ifdef PNG_READ_GAMMA_SUPPORTED 3401 if (gamma_16 != NULL)
3404 for (i = 0; i < row_width; i++, sp += 2)
3408 v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3410 if (v == png_ptr->trans_color.gray)
3413 *sp = (png_byte)((png_ptr->background.gray >> 8)
3415 *(sp + 1) = (png_byte)(png_ptr->background.gray
3421 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3422 *sp = (png_byte)((v >> 8) & 0xff);
3423 *(sp + 1) = (png_byte)(v & 0xff);
3431 for (i = 0; i < row_width; i++, sp += 2)
3435 v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3437 if (v == png_ptr->trans_color.gray)
3439 *sp = (png_byte)((png_ptr->background.gray >> 8)
3441 *(sp + 1) = (png_byte)(png_ptr->background.gray
3459 #ifdef PNG_READ_GAMMA_SUPPORTED 3460 if (gamma_table != NULL)
3463 for (i = 0; i < row_width; i++, sp += 3)
3465 if (*sp == png_ptr->trans_color.red &&
3466 *(sp + 1) == png_ptr->trans_color.green &&
3467 *(sp + 2) == png_ptr->trans_color.blue)
3469 *sp = (png_byte)png_ptr->background.red;
3470 *(sp + 1) = (png_byte)png_ptr->background.green;
3471 *(sp + 2) = (png_byte)png_ptr->background.blue;
3476 *sp = gamma_table[*sp];
3477 *(sp + 1) = gamma_table[*(sp + 1)];
3478 *(sp + 2) = gamma_table[*(sp + 2)];
3486 for (i = 0; i < row_width; i++, sp += 3)
3488 if (*sp == png_ptr->trans_color.red &&
3489 *(sp + 1) == png_ptr->trans_color.green &&
3490 *(sp + 2) == png_ptr->trans_color.blue)
3492 *sp = (png_byte)png_ptr->background.red;
3493 *(sp + 1) = (png_byte)png_ptr->background.green;
3494 *(sp + 2) = (png_byte)png_ptr->background.blue;
3501 #ifdef PNG_READ_GAMMA_SUPPORTED 3502 if (gamma_16 != NULL)
3505 for (i = 0; i < row_width; i++, sp += 6)
3507 png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3509 png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
3512 png_uint_16
b = (png_uint_16)(((*(sp + 4)) << 8)
3515 if (r == png_ptr->trans_color.red &&
3516 g == png_ptr->trans_color.green &&
3517 b == png_ptr->trans_color.blue)
3520 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
3521 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
3522 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
3524 *(sp + 3) = (png_byte)(png_ptr->background.green
3526 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
3528 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
3533 png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3534 *sp = (png_byte)((v >> 8) & 0xff);
3535 *(sp + 1) = (png_byte)(v & 0xff);
3537 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3538 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3539 *(sp + 3) = (png_byte)(v & 0xff);
3541 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3542 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3543 *(sp + 5) = (png_byte)(v & 0xff);
3552 for (i = 0; i < row_width; i++, sp += 6)
3554 png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3556 png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
3559 png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
3562 if (r == png_ptr->trans_color.red &&
3563 g == png_ptr->trans_color.green &&
3564 b == png_ptr->trans_color.blue)
3566 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
3567 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
3568 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
3570 *(sp + 3) = (png_byte)(png_ptr->background.green
3572 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
3574 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
3586 #ifdef PNG_READ_GAMMA_SUPPORTED 3587 if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
3588 gamma_table != NULL)
3591 for (i = 0; i < row_width; i++, sp += 2)
3593 png_uint_16
a = *(sp + 1);
3596 *sp = gamma_table[*sp];
3601 *sp = (png_byte)png_ptr->background.gray;
3608 v = gamma_to_1[*sp];
3611 w = gamma_from_1[w];
3620 for (i = 0; i < row_width; i++, sp += 2)
3622 png_byte a = *(sp + 1);
3625 *sp = (png_byte)png_ptr->background.gray;
3634 #ifdef PNG_READ_GAMMA_SUPPORTED 3635 if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
3636 gamma_16_to_1 != NULL)
3639 for (i = 0; i < row_width; i++, sp += 4)
3641 png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
3644 if (a == (png_uint_16)0xffff)
3648 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3649 *sp = (png_byte)((v >> 8) & 0xff);
3650 *(sp + 1) = (png_byte)(v & 0xff);
3656 *sp = (png_byte)((png_ptr->background.gray >> 8)
3658 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
3663 png_uint_16 g, v, w;
3665 g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3670 w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
3671 *sp = (png_byte)((w >> 8) & 0xff);
3672 *(sp + 1) = (png_byte)(w & 0xff);
3680 for (i = 0; i < row_width; i++, sp += 4)
3682 png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
3687 *sp = (png_byte)((png_ptr->background.gray >> 8)
3689 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
3692 else if (a < 0xffff)
3696 g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3698 *sp = (png_byte)((v >> 8) & 0xff);
3699 *(sp + 1) = (png_byte)(v & 0xff);
3711 #ifdef PNG_READ_GAMMA_SUPPORTED 3712 if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
3713 gamma_table != NULL)
3716 for (i = 0; i < row_width; i++, sp += 4)
3718 png_byte a = *(sp + 3);
3722 *sp = gamma_table[*sp];
3723 *(sp + 1) = gamma_table[*(sp + 1)];
3724 *(sp + 2) = gamma_table[*(sp + 2)];
3730 *sp = (png_byte)png_ptr->background.red;
3731 *(sp + 1) = (png_byte)png_ptr->background.green;
3732 *(sp + 2) = (png_byte)png_ptr->background.blue;
3739 v = gamma_to_1[*sp];
3741 if (optimize == 0) w = gamma_from_1[w];
3744 v = gamma_to_1[*(sp + 1)];
3746 if (optimize == 0) w = gamma_from_1[w];
3749 v = gamma_to_1[*(sp + 2)];
3751 if (optimize == 0) w = gamma_from_1[w];
3760 for (i = 0; i < row_width; i++, sp += 4)
3762 png_byte a = *(sp + 3);
3766 *sp = (png_byte)png_ptr->background.red;
3767 *(sp + 1) = (png_byte)png_ptr->background.green;
3768 *(sp + 2) = (png_byte)png_ptr->background.blue;
3776 png_ptr->background.green);
3779 png_ptr->background.blue);
3786 #ifdef PNG_READ_GAMMA_SUPPORTED 3787 if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
3788 gamma_16_to_1 != NULL)
3791 for (i = 0; i < row_width; i++, sp += 8)
3793 png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
3794 << 8) + (png_uint_16)(*(sp + 7)));
3796 if (a == (png_uint_16)0xffff)
3800 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3801 *sp = (png_byte)((v >> 8) & 0xff);
3802 *(sp + 1) = (png_byte)(v & 0xff);
3804 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3805 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3806 *(sp + 3) = (png_byte)(v & 0xff);
3808 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3809 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3810 *(sp + 5) = (png_byte)(v & 0xff);
3816 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
3817 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
3818 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
3820 *(sp + 3) = (png_byte)(png_ptr->background.green
3822 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
3824 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
3831 v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3834 w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
3836 *sp = (png_byte)((w >> 8) & 0xff);
3837 *(sp + 1) = (png_byte)(w & 0xff);
3839 v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
3842 w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
3845 *(sp + 2) = (png_byte)((w >> 8) & 0xff);
3846 *(sp + 3) = (png_byte)(w & 0xff);
3848 v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
3851 w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
3854 *(sp + 4) = (png_byte)((w >> 8) & 0xff);
3855 *(sp + 5) = (png_byte)(w & 0xff);
3864 for (i = 0; i < row_width; i++, sp += 8)
3866 png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
3867 << 8) + (png_uint_16)(*(sp + 7)));
3871 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
3872 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
3873 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
3875 *(sp + 3) = (png_byte)(png_ptr->background.green
3877 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
3879 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
3882 else if (a < 0xffff)
3886 png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
3887 png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
3889 png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
3893 *sp = (png_byte)((v >> 8) & 0xff);
3894 *(sp + 1) = (png_byte)(v & 0xff);
3897 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3898 *(sp + 3) = (png_byte)(v & 0xff);
3901 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3902 *(sp + 5) = (png_byte)(v & 0xff);
#define png_composite(composite, fg, alpha, bg)
Definition: png.h:2662
int i
Definition: rw_test.cpp:37
const png_uint_16p * png_const_uint_16pp
Definition: pngpriv.h:838
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:813
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:812
long b
Definition: jpegint.h:371
png_uint_32 width
Definition: png.h:896
static double * p
Definition: gauss_jackson_test.cpp:42
png_byte color_type
Definition: png.h:898
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
const png_byte * png_const_bytep
Definition: pngconf.h:601
Definition: eci2kep_test.cpp:33
#define png_composite_16(composite, fg, alpha, bg)
Definition: png.h:2669
png_byte bit_depth
Definition: png.h:899
#define PNG_FLAG_OPTIMIZE_ALPHA
Definition: pngpriv.h:614