Anonymous user
Raster graphics operations/Ruby: Difference between revisions
m
→The Code
mNo edit summary |
m (→The Code) |
||
Line 2:
==The Code==
Collecting all the Ruby code from [[:Category:Raster graphics operations]], so one can invoke: <code>require 'raster_graphics'</code>
Uses the [https://github.com/wvanbergen/chunky_png ChunkyPNG] pure-Ruby PNG library.
<lang ruby>###########################################################################
# Represents an RGB[http://en.wikipedia.org/wiki/Rgb] colour.
Line 166 ⟶ 169:
def save_as_png(filename)
require 'chunky_png'
stream = StringIO.new("", "r+")
each_pixel {|x, y| stream << self[x, y].values.pack("ccc")}
|