This is not necessarily the current version of this TIP.
|Title:||PNG Photo Image Support for Tk|
|Version:||$Revision: 1.6 $|
|Author:||Michael Kirkham <mikek at muonics dot com>|
|Created:||Tuesday, 22 March 2005|
Tk's photo image type has had support for alpha channels internally since version 8.3. However, to date there is no photo format in the core that exposes this functionality. This TIP proposes adding support for the PNG (Portable Network Graphics) format.
There is a current push for "beautifying" Tcl/Tk with more modern appearing widgets and default configuration options. One method that can provide significant improvement in appearance is the use of images with alpha channels for antialiasing and smooth blending into the background of the GUI. While the Tk core supports alpha channels, this support is neither exposed through the Tk_GetColor() format used by image put and similar interfaces, nor by the only photo image format, GIF, which allows only fully-opaque or fully-transparent pixels. Instead, a third party package is currently required to add a format supporting alpha channels, which may not have a suitable license or increase the number of external dependencies unreasonably.
The PNG image format is an open standard supporting a wide range of colors, from 1 bit per pixel black and white to 16 bit per pixel RGBA, with loss-less compression. It's becoming increasingly widely used as the image format of choice in many areas including GUI and web page design for its color range, alpha support and small image size. As such it is the obvious choice for adding alpha support to Tk. An implementation can be light-weight and not add any new dependencies (such as on libpng) to Tk: while the format also depends on the zlib format for compression, TIP #234 proposes zlib support for the Tcl core.
The implementation shall use the Tk_CreatePhotoImageFormat() mechanisms to supply handlers to Tk for PNG support. The implementation must:
Support the full range of color types and bit depths allowed and required by the PNG standard, including alpha channels and boolean transparency.
Support reading of interlaced images.