# File lib/PatchedPNG.rb, line 77 def save(path) File.open(path, "w") do |f| f.write [137, 80, 78, 71, 13, 10, 26, 10].pack("C*") # PNG signature f.write PNG.chunk('IHDR', [ @height, @width, @bits, 6, 0, 0, 0 ].pack("N2C5")) # 0 == filter type code "none" data = @data.map { |row| [0] + row.map { |p| p.values } }.flatten f.write PNG.chunk('IDAT', Zlib::Deflate.deflate(data.pack("C*"), 9)) f.write PNG.chunk('IEND', '') end end