PNG Datatype Handler for BeOS
This is an image datatype based upon libpng and zlib that can display and save files in the PNG
format. For information on first time usage, please look at the FAQ later in this document.
The PNG format is an excellent loss-less format that can replace and
improve formats such as GIF and some of the common uses of TIFF. Sampling depths can
be from 1 to 16 bits; it supports indexed-palette; true colour and
grayscale images with an optional alpha channel. It is now even an Internet
standard (RFC).
For more information please look at http://www.wco.com/~png
Understanding the Preferences
You can access the preference dialogue directly by double clicking on /boot/home/config/add-ons/Datatypes/PNGHandler or where ever you have set your datatypes to be
located - see the FAQ for more information.
There you can configure all the saving options for the PNGHandler. Programmers can also make use of this dialogue within their applications, so you might often see this panel in other programs.
It is worth remember that whenever the dialogue is closed your settings will be automatically saved for you, and become active immediately.
Output Depth allows you to select what bit depth you would like the image to be saved as. 32-bit Alpha Colour preserves
the alpha channel of the image, and can often produce large images. 24-bit True Colour is the same 32-bit Alpha Colour, but
does not perserve the alpha channel in the output image. 8-bit Paletted Colour allows you to save the image in 256 colours
or less, the 8-bit Colours lets you select this.
8-bit Colours allows you to configure how many colours will be in the final image when saving as an 8-bit Paletted Colour image - otherwise
this option will be ghosted.
Colour Mapping is a setting that applies to 8-bit Paletted Colour saving only. This lets you define how carefully
the handler will convert the high quality input to your choosen output colour number. Basic Mapping is designed to be very
quick, and only lets you convert to 256 colours. Slow Mapping is a better choice, and lets you define a variable number of
colours in the 8-bit Colours selector, and will generally produce better looking images.
Output Type lets you set how the image lines are stored in the PNG file. Creating a file as interlaced will display the
nice blind effect when downloading the file from a network, and can result in smaller files. When generating interlaced files
extra memory is used, and it can be slower to encode.
Compression allows you to set how the handler will try and reduce the size of the final output file. Default is a kind of
hybrid between speed of compression and the final size of the output file. Best for Speed will try and compress the file
as quickly as possible; Best for Size will try and make the output file as small as possible. If you set Compression to None,
files will be written very quickly, but will most likely be very large.
Programmers Information
ALWAYS try and pass the PNGHandler 32-bit data to convert to a PNG
if its at all possible, since when you pass the handler 8-bit data all it
is doing is expanding it to 32-bit data using the default Be colour map. This also holds true for all other datatypes
unless you are given the option of sending the datatype a colour map.
Finally, please remember, there are two ways to check if a datatype supports
progressive image decoding through the MEDIAStream format, firstly check
through its output formats to find DATA_MEDIA or call DATATranslate() with
an outtype of DATA_MEDIA, and be prepared for it to fail. You then try and
translate it with DATA_BITMAP.
N.B. When you pass 8 bit data to the convert to the PNG format, the
datatype will use the system_colors()->color_list to expand the data
into 32-bit.
Standard colour space extensions apply.
Program History
1.00
Inital Release
1.11
Fixed bug that caused problems with palette. Thanks to Philippe
Thomas for the bug report.
Fixed really stupid bug that caused images with a depth lower than
4 bits per component to crash - thanks again to Philippe Thomas for
the bug report.
Added progressive and PNG`s own Adam7 interlace format support
through the MEDIAStream format. If you want your application to
support this, please request the image as a DATA_MEDIA, be
prepared for this to fail and to re-request as a DATA_BITMAP.
Added interlace and more depth options to preference view.
Fixed grayscale images, they are now returned as a B_RGB_32_BIT
bitmap.
Linked against latest libpng 0.96 and zlib 1.0.4.
DR9 AA version. Better error handling. Additional type checking in
Identify() function. Fixed 8 bit input data for save routine.
Added some text comments to images.
1.15
Changed standard output to be written in steps. Fixed 8-bit output
of images (Thanks to Edmund Vermeulen for the report). Fixed
memory leak in progressive code. Ported to DR9 Preview and
Datatypes 1.6.1. Added extra output depths.
1.16
Compiled under Datatypes 1.6.3. Configuration file was being
written to the wrong place (opps) - fixed. Rewrote the documentation in HTML.
1.17
Alpha changed to 255 for opaque, as required by PR2.
Special Thanks To
Jon Watte, Jeremy Moskovish, Philippe Thomas and Edmund Vermeulen.
License
There is no warranty with this program, and I have no liability for any consequential
damage arising from the use of or inability to use this program. In no
event shall I be liable for any damages whatsoever.
Distribution with any commerical software is strictly forbidden, either in full or demo form without a license agreement. Distribution is
also forbidden on any software collections costing over 50USD.
By reading this file and using the handler you are agreeing to the terms listed here.
Q: How do I install it?
A: You need to place it in your datatypes directory. As default this is /boot/home/config/add-ons/Datatypes, but this may be configured differently. See the Datatypes manual, which came with your install of the Datatypes package for more details.
Q: What is this program used for?
A: The PNGHandler allows programs which support datatypes to load and save PNG
images. You can use ShowApp which is included with the Datatypes package to view any images in this format, but other viewers are available; one of my favourites is DTPicView by Edmund Vermeulen.
Q: Will NetPositive use the PNGHandler?
A: No, NetPositive does not currently support datatypes, and has no internal ability to
display PNG files.
Q: What is an alpha channel?
A: The alpha channel of an image is normally a extra byte of information added to every pixel
that tells the program that is viewing it how transparent that pixel should be. It is often refered to as 32-bit
colour because it adds an extra 8 bits (1 byte) to the standard 24-bit RGB pixel.
PNG is one of the few image formats that gives you an option to perserve this alpha channel.
Q:What is zlib?
A: zlib is the name of the system which compresses the image data within PNG files. It is
written by Jean-loup Gailly and Mark Adler.
Contact Details
Simon Clarke (S.J.Clarke@herts.ac.uk)
If you want to distribute this handler and a user help version of this document with your application, please email me.
If there are any files which this handler does not display correctly, please let me know, and I can try and fix the
problem.