~ubuntu-branches/ubuntu/intrepid/libpng/intrepid-security

« back to all changes in this revision

Viewing changes to libpng.3

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2005-10-03 20:18:43 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051003201843-cv2i5v7no1ff08tx
Tags: 1.2.8rel-5
* drop_pass_width.patch: don't export png_pass_width, it's absolutely 
  unnecessary.
* libpng12-0.shlibs: downgrade the shlibs accordingly
  (closes: #331383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
.TH LIBPNG 3 "December 3, 2004"
2
2
.SH NAME
3
 
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.18
 
3
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.8
4
4
.SH SYNOPSIS
5
5
\fI\fB
6
6
 
781
781
.SH LIBPNG.TXT
782
782
libpng.txt - A description on how to use and modify libpng
783
783
 
784
 
 libpng version 1.0.18 - December 3, 2004
 
784
 libpng version 1.2.8 - December 3, 2004
785
785
 Updated and distributed by Glenn Randers-Pehrson
786
786
 <glennrp at users.sourceforge.net>
787
787
 Copyright (c) 1998-2004 Glenn Randers-Pehrson
1084
1084
 
1085
1085
    png_set_read_status_fn(png_ptr, read_row_callback);
1086
1086
 
 
1087
.SS Width and height limits
 
1088
 
 
1089
The PNG specification allows the width and height of an image to be as
 
1090
large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
 
1091
Since very few applications really need to process such large images,
 
1092
we have imposed an arbitrary 1-million limit on rows and columns.
 
1093
Larger images will be rejected immediately with a png_error() call. If
 
1094
you wish to override this limit, you can use
 
1095
 
 
1096
   png_set_user_limits(png_ptr, width_max, height_max);
 
1097
 
 
1098
to set your own limits, or use width_max = height_max = 0x7fffffffL
 
1099
to allow all valid dimensions (libpng may reject some very large images
 
1100
anyway because of potential buffer overflow conditions).
 
1101
 
 
1102
You should put this statement after you create the PNG structure and
 
1103
before calling png_read_info(), png_read_png(), or png_process_data().
 
1104
If you need to retrieve the limits that are being applied, use
 
1105
 
 
1106
   width_max = png_get_user_width_max(png_ptr);
 
1107
   height_max = png_get_user_height_max(png_ptr);
 
1108
 
1087
1109
.SS Unknown-chunk handling
1088
1110
 
1089
1111
Now you get to set the way the library processes unknown chunks in the
1526
1548
For example, 4 bit/pixel paletted or grayscale data will be returned
1527
1549
2 pixels/byte with the leftmost pixel in the high-order bits of the
1528
1550
byte, unless png_set_packing() is called.  8-bit RGB data will be stored
1529
 
in RGB RGB RGB format unless png_set_filler()
 
1551
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
1530
1552
is called to insert filler bytes, either before or after each RGB triplet.
1531
1553
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
1532
1554
byte of the color value first, unless png_set_strip_16() is called to
1534
1556
png_set_add alpha() is called to insert filler bytes, either before or
1535
1557
after each RRGGBB triplet.  Similarly, 8-bit or 16-bit grayscale data can
1536
1558
be modified with
1537
 
png_set_filler() or png_set_strip_16().
 
1559
png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
1538
1560
 
1539
1561
The following code transforms grayscale images of less than 8 to 8 bits,
1540
1562
changes paletted images to RGB, and adds a full alpha channel if there is
1619
1641
opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
1620
1642
will generate RGBA pixels.
1621
1643
 
 
1644
Note that png_set_filler() does not change the color type.  If you want
 
1645
to do that, you can add a true alpha channel with
 
1646
 
 
1647
    if (color_type == PNG_COLOR_TYPE_RGB ||
1622
1648
           color_type == PNG_COLOR_TYPE_GRAY)
 
1649
    png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
 
1650
 
 
1651
where "filler" contains the alpha value to assign to each pixel.
 
1652
This function was added in libpng-1.2.7.
 
1653
 
1623
1654
If you are reading an image with an alpha channel, and you need the
1624
1655
data as ARGB instead of the normal PNG format RGBA:
1625
1656
 
3459
3490
having level = 0 will be printed.  There aren't any such statements in
3460
3491
this version of libpng, but if you insert some they will be printed.
3461
3492
 
3462
 
.SH VI.  MNG support
 
3493
.SH VI.  Runtime optimization
 
3494
 
 
3495
A new feature in libpng 1.2.0 is the ability to dynamically switch between
 
3496
standard and optimized versions of some routines.  Currently these are
 
3497
limited to three computationally intensive tasks when reading PNG files:
 
3498
decoding row filters, expanding interlacing, and combining interlaced or
 
3499
transparent row data with previous row data.  Currently the optimized
 
3500
versions are available only for x86 (Intel, AMD, etc.) platforms with
 
3501
MMX support, though this may change in future versions.  (For example,
 
3502
the non-MMX assembler optimizations for zlib might become similarly
 
3503
runtime-selectable in future releases, in which case libpng could be
 
3504
extended to support them.  Alternatively, the compile-time choice of
 
3505
floating-point versus integer routines for gamma correction might become
 
3506
runtime-selectable.)
 
3507
 
 
3508
Because such optimizations tend to be very platform- and compiler-dependent,
 
3509
both in how they are written and in how they perform, the new runtime code
 
3510
in libpng has been written to allow programs to query, enable, and disable
 
3511
either specific optimizations or all such optimizations.  For example, to
 
3512
enable all possible optimizations (bearing in mind that some "optimizations"
 
3513
may actually run more slowly in rare cases):
 
3514
 
 
3515
    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
 
3516
       png_uint_32 mask, flags;
 
3517
 
 
3518
       flags = png_get_asm_flags(png_ptr);
 
3519
       mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
 
3520
       png_set_asm_flags(png_ptr, flags | mask);
 
3521
    #endif
 
3522
 
 
3523
To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ
 
3524
by itself when calling png_get_asm_flagmask(); similarly for optimizing
 
3525
only writing.  To disable all optimizations:
 
3526
 
 
3527
    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
 
3528
       flags = png_get_asm_flags(png_ptr);
 
3529
       mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
 
3530
       png_set_asm_flags(png_ptr, flags & ~mask);
 
3531
    #endif
 
3532
 
 
3533
To enable or disable only MMX-related features, use png_get_mmx_flagmask()
 
3534
in place of png_get_asm_flagmask().  The mmx version takes one additional
 
3535
parameter:
 
3536
 
 
3537
    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
 
3538
       int selection = PNG_SELECT_READ | PNG_SELECT_WRITE;
 
3539
       int compilerID;
 
3540
 
 
3541
       mask = png_get_mmx_flagmask(selection, &compilerID);
 
3542
    #endif
 
3543
 
 
3544
On return, compilerID will indicate which version of the MMX assembler
 
3545
optimizations was compiled.  Currently two flavors exist:  Microsoft
 
3546
Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2).
 
3547
On non-x86 platforms or on systems compiled without MMX optimizations, a
 
3548
value of -1 is used.
 
3549
 
 
3550
Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return
 
3551
all valid, settable optimization bits for the version of the library that's
 
3552
currently in use.  In the case of shared (dynamically linked) libraries,
 
3553
this may include optimizations that did not exist at the time the code was
 
3554
written and compiled.  It is also possible, of course, to enable only known,
 
3555
specific optimizations; for example:
 
3556
 
 
3557
    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
 
3558
       flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
 
3559
             | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
 
3560
             | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
 
3561
             | PNG_ASM_FLAG_MMX_READ_FILTER_UP    \
 
3562
             | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
 
3563
             | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
 
3564
       png_set_asm_flags(png_ptr, flags);
 
3565
    #endif
 
3566
 
 
3567
This method would enable only the MMX read-optimizations available at the
 
3568
time of libpng 1.2.0's release, regardless of whether a later version of
 
3569
the DLL were actually being used.  (Also note that these functions did not
 
3570
exist in versions older than 1.2.0, so any attempt to run a dynamically
 
3571
linked app on such an older version would fail.)
 
3572
 
 
3573
To determine whether the processor supports MMX instructions at all, use
 
3574
the png_mmx_support() function:
 
3575
 
 
3576
    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
 
3577
       mmxsupport = png_mmx_support();
 
3578
    #endif
 
3579
 
 
3580
It returns -1 if MMX support is not compiled into libpng, 0 if MMX code
 
3581
is compiled but MMX is not supported by the processor, or 1 if MMX support
 
3582
is fully available.  Note that png_mmx_support(), png_get_mmx_flagmask(),
 
3583
and png_get_asm_flagmask() all may be called without allocating and ini-
 
3584
tializing any PNG structures (for example, as part of a usage screen or
 
3585
"about" box).
 
3586
 
 
3587
The following code can be used to prevent an application from using the
 
3588
thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK
 
3589
defined:
 
3590
 
 
3591
#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
 
3592
  && defined(PNG_THREAD_UNSAFE_OK)
 
3593
    /* Disable thread-unsafe features of pnggccrd */
 
3594
    if (png_access_version() >= 10200)
 
3595
    {
 
3596
      png_uint_32 mmx_disable_mask = 0;
 
3597
      png_uint_32 asm_flags;
 
3598
 
 
3599
      mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
 
3600
                          | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
 
3601
                          | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
 
3602
                          | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
 
3603
      asm_flags = png_get_asm_flags(png_ptr);
 
3604
      png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
 
3605
    }
 
3606
#endif
 
3607
 
 
3608
For more extensive examples of runtime querying, enabling and disabling
 
3609
of optimized features, see contrib/gregbook/readpng2.c in the libpng
 
3610
source-code distribution.
 
3611
 
 
3612
.SH VII.  MNG support
3463
3613
 
3464
3614
The MNG specification (available at http://www.libpng.org/pub/mng) allows
3465
3615
certain extensions to PNG for PNG images that are embedded in MNG datastreams.
3484
3634
them.  You may wish to consider using libmng (available at
3485
3635
http://www.libmng.com) instead.
3486
3636
 
3487
 
.SH VII.  Changes to Libpng from version 0.88
 
3637
.SH VIII.  Changes to Libpng from version 0.88
3488
3638
 
3489
3639
It should be noted that versions of libpng later than 0.96 are not
3490
3640
distributed by the original libpng author, Guy Schalnat, nor by
3533
3683
 
3534
3684
   png_uint_32 application_vn = PNG_LIBPNG_VER;
3535
3685
 
3536
 
.SH VIII. Y2K Compliance in libpng
 
3686
.SH IX. Y2K Compliance in libpng
3537
3687
 
3538
3688
December 3, 2004
3539
3689
 
3541
3691
an official declaration.
3542
3692
 
3543
3693
This is your unofficial assurance that libpng from version 0.71 and
3544
 
upward through 1.0.18 are Y2K compliant.  It is my belief that earlier
 
3694
upward through 1.2.8 are Y2K compliant.  It is my belief that earlier
3545
3695
versions were also Y2K compliant.
3546
3696
 
3547
3697
Libpng only has three year fields.  One is a 2-byte unsigned integer that
3749
3899
 
3750
3900
Thanks to Frank J. T. Wojcik for helping with the documentation.
3751
3901
 
3752
 
Libpng version 1.0.18 - December 3, 2004:
 
3902
Libpng version 1.2.8 - December 3, 2004:
3753
3903
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
3754
3904
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
3755
3905