Hi,
is it possible to use an indexed png's palette and accompanying transparency data to display a masked image? I've seen enough evidence in other opensource pdf libraries to suggest that it's possible, but am having trouble getting it working myself.
The indexed PNG's i've tested all contain an array of palette data and an associated array of transparency values.
I'm able to successfully display the png in a pdf, when only using it's palette and excluding the transprancy. The transparent parts of the image are displayed as black, as expected . The outuput is,
17 0 obj
<</Type /XObject
/Subtype /Image
/Width 16
/Height 16
/ColorSpace [/Indexed /DeviceRGB 15 18 0 R]
/BitsPerComponent 4
/Filter /FlateDecode
/DecodeParms <</Predictor 15 /Colors 1 /BitsPerComponent 4 /Columns 16>>
/Length 155>>
stream
--------------- BINARY IMAGE DATA ---------------
endstream
endobj
18 0 obj
<< /Length 48>>
stream
--------------- PALETTE ARRAY VALUES AS BINARY ---------------
endstream
endobj
But as soon as i try an add the transparency array, nothing gets displayed and i get an error when opening the pdf that says 'An error exists on this page'. The transparency values for the indexed image are as follows,
[255, 255, 192, 192, 160, 160, 128, 128, 96, 96, 64, 64, 32, 32, 0, 0]
I've followed the spec, 8.9.6.4 Colour Key Masking, although i'm not sure if there should be a difference between 'min' and 'max' or whether it's just the same value duplicated? From the logic i've seen in other pdf generation libraries, it appears to be the latter.
This is the non working output i get, when attempting to use the above array of transparency values as a mask,
17 0 obj
<</Type /XObject
/Subtype /Image
/Width 16
/Height 16
/ColorSpace [/Indexed /DeviceRGB 15 18 0 R]
/BitsPerComponent 4
/Filter /FlateDecode
/DecodeParms <</Predictor 15 /Colors 1 /BitsPerComponent 4 /Columns 16>>
/Mask [255 255 255 255 192 192 192 192 160 160 160 160 128 128 128 128 96 96 96 96 64 64 64 64 32 32 32 32 0 0 0 0 ]
/Length 155>>
stream
--------------- BINARY IMAGE DATA ---------------
endstream
endobj
18 0 obj
<< /Length 48>>
stream
--------------- PALETTE ARRAY VALUES AS BINARY ---------------
endstream
endobj