Image-PNG-Simple

 view release on metacpan or  search on metacpan

libpng-1.6.17/libpng-manual.txt  view on Meta::CPAN

1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
The default values come from the PNG file cHRM chunk if present; otherwise, the
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
space, as recommended in the Charles Poynton's Colour FAQ,
<http://www.poynton.com/>, in section 9:
 
 
    Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
 
Previous versions of this document, 1998 through 2002, recommended a slightly
different formula:
 
    Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
 
Libpng uses an integer approximation:
 
    Y = (6968 * R + 23434 * G + 2366 * B)/32768
 
The calculation is done in a linear colorspace, if the image gamma
can be determined.

libpng-1.6.17/libpng.3  view on Meta::CPAN

2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
The default values come from the PNG file cHRM chunk if present; otherwise, the
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
space, as recommended in the Charles Poynton's Colour FAQ,
<http://www.poynton.com/>, in section 9:
 
 
    Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
 
Previous versions of this document, 1998 through 2002, recommended a slightly
different formula:
 
    Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
 
Libpng uses an integer approximation:
 
    Y = (6968 * R + 23434 * G + 2366 * B)/32768
 
The calculation is done in a linear colorspace, if the image gamma
can be determined.

libpng-1.6.17/png.c  view on Meta::CPAN

3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
* We want log2(value/65535), we have log2(v'/255), where:
*
*    value = v' * 256 + v''
*          = v' * f
*
* So f is value/v', which is equal to (256+v''/v') since v' is in the range 128
* to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less
* than 258.  The final factor also needs to correct for the fact that our 8-bit
* value is scaled by 255, whereas the 16-bit values must be scaled by 65535.
*
* This gives a final formula using a calculated value 'x' which is value/v' and
* scaling by 65536 to match the above table:
*
*   log2(x/257) * 65536
*
* Since these numbers are so close to '1' we can use simple linear
* interpolation between the two end values 256/257 (result -368.61) and 258/257
* (result 367.179).  The values used below are scaled by a further 64 to give
* 16-bit precision in the interpolation:
*
* Start (256): -23591

libpng-1.6.17/pngrtran.c  view on Meta::CPAN

4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
int r, g, b, p;
sp = row;
dp = row;
for (i = 0; i < row_width; i++)
{
   r = *sp++;
   g = *sp++;
   b = *sp++;
 
   /* This looks real messy, but the compiler will reduce
    * it down to a reasonable formula.  For example, with
    * 5 bits per color, we get:
    * p = (((r >> 3) & 0x1f) << 10) |
    *    (((g >> 3) & 0x1f) << 5) |
    *    ((b >> 3) & 0x1f);
    */
   p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
       ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
       (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
       (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
       ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<

zlib-1.2.8/adler32.c  view on Meta::CPAN

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    z_off64_t len2;
{
    unsigned long sum1;
    unsigned long sum2;
    unsigned rem;
 
    /* for negative len, return invalid adler32 as a clue for debugging */
    if (len2 < 0)
        return 0xffffffffUL;
 
    /* the derivation of this formula is left as an exercise for the reader */
    MOD63(len2);                /* assumes len2 >= 0 */
    rem = (unsigned)len2;
    sum1 = adler1 & 0xffff;
    sum2 = rem * sum1;
    MOD(sum2);
    sum1 += (adler2 & 0xffff) + BASE - 1;
    sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
    if (sum1 >= BASE) sum1 -= BASE;
    if (sum1 >= BASE) sum1 -= BASE;
    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);



( run in 0.729 second using v1.01-cache-2.11-cpan-5f2e87ce722 )