Author stephen
Recipients giacomo.boffi
Date 2009-09-22.16:47:08
I know how to fix it basically, but need to go to bed now.

The basic problem is that we are getting a PNG which uses both an RGB palette 
(what X11 would call PseudoColor) and transparency data (an alpha channel).  
The crash is caused because the presence of the transparency data causes libpng 
to fill our buffer (which expects RGB data) with RGBA data, ie 33% too much.  
This overrun is restricted to the last row because of the way libpng fills the 
buffer.  It occurs regardless of the strip_alpha setting, because the stripping 
is done in-place in our buffer.  This is handled by adding padding to the end 
of the unwind.eimage buffer.  It would be nice if somehow we could avoid it (it 
amounts to 5 * pixel_width bytes), but that would be a bit complicated.

A second problem then becomes apparent: the alpha channel is not actually being 
stripped.  The png_info structure does not have a unified way to determine if 
there is an alpha channel.  Instead you have to check for color_type & 
MASK_ALPHA for true RGB, and for num_trans > 0 for PALETTE + TRANS.  Our code 
only did the former, so the image was displayed incorrectly.  Unfortunately, 
it's not well-documented for all the possibilities, so I need to study the 
library code before submitting a patch.
Date User Action Args
2009-09-22 16:47:08stephensetmessageid: <>
2009-09-22 16:47:08stephensetrecipients: + giacomo.boffi
2009-09-22 16:47:08stephenlinkissue570 messages
2009-09-22 16:47:08stephencreate