lib/prawn/images/png.rb in prawn-2.0.1 vs lib/prawn/images/png.rb in prawn-2.0.2

- old
+ new

@@ -66,13 +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 - raise Errors::UnsupportedImageType, - "Pallete-based transparency in PNG is not currently supported.\n" + - "See https://github.com/prawnpdf/prawn/issues/783" + fail 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 @@ -119,22 +119,22 @@ # Build a PDF object representing this image in +document+, and return # a Reference to it. # def build_pdf_object(document) if compression_method != 0 - raise Errors::UnsupportedImageType, - 'PNG uses an unsupported compression method' + fail Errors::UnsupportedImageType, + 'PNG uses an unsupported compression method' end if filter_method != 0 - raise Errors::UnsupportedImageType, - 'PNG uses an unsupported filter method' + fail Errors::UnsupportedImageType, + 'PNG uses an unsupported filter method' end if interlace_method != 0 - raise Errors::UnsupportedImageType, - 'PNG uses unsupported interlace method' + fail Errors::UnsupportedImageType, + 'PNG uses unsupported interlace method' end # some PNG types store the colour and alpha channel data together, # which the PDF spec doesn't like, so split it out. split_alpha_channel! @@ -143,12 +143,12 @@ when 1 color = :DeviceGray when 3 color = :DeviceRGB else - raise Errors::UnsupportedImageType, - "PNG uses an unsupported number of colors (#{png.colors})" + fail Errors::UnsupportedImageType, + "PNG uses an unsupported number of colors (#{png.colors})" end # build the image dict obj = document.ref!( :Type => :XObject, @@ -179,11 +179,11 @@ palette_obj << palette # build the color space array for the image obj.data[:ColorSpace] = [:Indexed, :DeviceRGB, - (palette.size / 3) -1, + (palette.size / 3) - 1, palette_obj] end # ************************************* # add transparency data if necessary @@ -201,10 +201,10 @@ elsif transparency[:rgb] # 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 + obj.data[:Mask] = rgb.collect { |x| [x, x] }.flatten 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