Class PNG
In: lib/png/pie.rb
lib/png/reader.rb
lib/png.rb
Parent: Object

An almost-pure-ruby Portable Network Graphics (PNG) writer.

www.libpng.org/pub/png/spec/1.2/

PNG supports: + 8 bit truecolor PNGs

PNG does not support: + any other color depth + extra data chunks + filters

Example

  require 'png'

  canvas = PNG::Canvas.new 200, 200
  canvas[100, 100] = PNG::Color::Black
  canvas.line 50, 50, 100, 50, PNG::Color::Blue
  png = PNG.new canvas
  png.save 'blah.png'

TODO:

+ Get everything orinted entirely on [x,y,h,w] with x,y origin being

  bottom left.

Methods

angle   check_crc   chunk   load   load_file   new   paeth   pie_chart   png_join   read_IDAT   read_IHDR   read_chunk   save   to_blob  

Classes and Modules

Class PNG::Canvas
Class PNG::Color
Class PNG::Font

Constants

FULL = 360.0
HALF = FULL / 2
VERSION = '1.2.0'
SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack("C*")
GRAY = 0   Color Types:
RGB = 2
INDEXED = 3
GRAYA = 4
RGBA = 6
NONE = 0   Filter Types:
SUB = 1
UP = 2
AVG = 3
PAETH = 4

Public Class methods

Creates a PNG chunk of type type that contains data.

Creates a new PNG object using canvas

Makes a pie chart you can pass to PNG.new:

  png = PNG.new pie_chart(250, 0.30)
  png.save "pie.png"
  system 'open pie.png'

Public Instance methods

Writes the PNG to path.

Raw PNG data

[Validate]