Permalink
Browse files

Add example bug in PNG alpha channel unfiltering

The mathn library changes Fixnum division to return a
rational instead of a floored int. The `PNG#unfilter_image_data`
function relies on an implicit flooring.
  • Loading branch information...
1 parent cd3e1ba commit 23d3208f4019f46b899aae4555af7efed850d581 @scpike scpike committed Jun 20, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 bugs/png_alpha_channel_filter.rb
View
13 bugs/png_alpha_channel_filter.rb
@@ -0,0 +1,13 @@
+$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
+require 'prawn'
+
+image_file = File.expand_path('../../data/images/prawn.png', __FILE__)
+
+pdf = Prawn::Document.new
+pdf.image image_file
+pdf.render_file("works.pdf")
+
+require 'mathn' # Re-defines '/' operation !
+pdf = Prawn::Document.new
+pdf.image image_file
+pdf.render_file("broken.pdf")

0 comments on commit 23d3208

Please sign in to comment.