-
StumpyPNG.read(path) : Canvasread a PNG image file -
StumpyPNG.write(canvas, path)saves a canvas as a PNG image file -
StumpyPNG::RGBA, 16-bit rgba colorrgba.rred channelrgba.ggreen channelrgba.bblue channelrgba.aalpha channelrgba.to_rgba8returns a tuple of 4 8-bit values{ r, g, b, a}rgba.to_rgb8returns a tuple of 3 8-bit values{ r, g, b }
-
StumpyPNG::Canvas, two dimensional Array of RGBA valuecanvas.widthcanvas.heightcanvas.set_pixel(x, y)canvas.get_pixel(x, y)
-
StumpyPNG::PNG, helper class to store some state while parsing PNG files
require "stumpy_png"
canvas = StumpyPNG.read("foo.png")
r, g, b = canvas.get_pixel(0, 0).to_rgb8
puts "red=#{r}, green=#{g}, blue=#{b}"require "stumpy_png"
canvas = StumpyPNG::Canvas.new(256, 256)
(0...255).each do |x|
(0...255).each do |y|
# RGBA.from_rgb_n(values, bit_depth) is an internal helper method
# that creates an RGBA object from a rgb triplet with a given bit depth
color = StumpyPNG::RGBA.from_rgb_n([x, y, 255], 8)
canvas.set_pixel(x, y, color)
end
end
StumpyPNG.write(canvas, "rainbow.png")(See examples/ for more examples)
- Grayscale
- Grayscale + Alpha
- RGB
- RGB + Alpha
- Palette
- None
- Sub
- Up
- Average
- Paeth
- None
- Adam7
- tRNS
- cHRM
- gAMA
- iCCP
- sBIT
- sRGB
- tEXt
- zTXt
- iTXt
- bKGD
- hIST
- pHYs
- sPLT
- tIME
Only supports writing to a RGB + Alpha PNG image without any filters, interlacing or ancillary chunks.
