lib/prawn/images/png.rb in prawn-1.3.0 vs lib/prawn/images/png.rb in prawn-2.0.0
- old
+ new
@@ -66,17 +66,13 @@
# This chunk can only occur once and it must occur after the
# PLTE chunk and before the IDAT chunk
@transparency = {}
case @color_type
when 3
- # Indexed colour, RGB. Each byte in this chunk is an alpha for
- # the palette index in the PLTE ("palette") chunk up until the
- # last non-opaque entry. Set up an array, stretching over all
- # palette entries which will be 0 (opaque) or 1 (transparent).
- @transparency[:indexed] = data.read(chunk_size).unpack("C*")
- short = 255 - @transparency[:indexed].size
- @transparency[:indexed] += ([255] * short) if short > 0
+ raise Errors::UnsupportedImageType,
+ "Pallete-based transparency in PNG is not currently supported.\n" +
+ "See https://github.com/prawnpdf/prawn/issues/783"
when 0
# Greyscale. Corresponding to entries in the PLTE chunk.
# Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1
grayval = data.read(chunk_size).unpack("n").first
@transparency[:grayscale] = grayval
@@ -206,14 +202,9 @@
# Use Color Key Masking (spec section 4.8.5)
# - An array with N elements, where N is two times the number of color
# components.
rgb = transparency[:rgb]
obj.data[:Mask] = rgb.collect { |x| [x,x] }.flatten
- elsif transparency[:indexed]
- # TODO: broken. I was attempting to us Color Key Masking, but I think
- # we need to construct an SMask i think. Maybe do it inside
- # the PNG class, and store it in alpha_channel
- #obj.data[:Mask] = transparency[:indexed]
end
# For PNG color types 4 and 6, the transparency data is stored as a alpha
# channel mixed in with the main image data. The PNG class seperates
# it out for us and makes it available via the alpha_channel attribute