artemp/trac2github — Issue #478: semitransparency support for png256
Author: artemp
Created: 2011-10-09 20:36:31+00:00
State: open
Labels: Core_Library

Current png256 format allows only full opacity or full transparency pixels. Discussion about it can be found in http://trac.mapnik.org/ticket/202#comment:5. Now I'm presenting patch implementing mentioned solution: using 3 octrees, one per alpha range. Boundaries and assigned color numbers are computed based on image alpha distribution.
This allows more smooth transparency changes and eliminates jagged edges.

In attachment, beside patch and fixed files, there are: readme.txt with more info, some sample images for testing different cases and little program, that can be used to test png256 without need to compile all mapnik libraries. I used it while writing this fix to test different approaches.

In image attachments below You can see effects in different cases. Those images are divided to 3 columns:[[BR]]
- left : source image[[BR]]
- center : new algorithm[[BR]]
- right : previous algorithm

Codes are prepared against 0.7 branch (including latest fix to #445, #447).
I suggest testing in different scenarios before committing. It isn't perfect, but in most situations should be enough, without much cputime or image size trade off (only 10% longer time and bigger image).