Module: ChunkyPNG

Extended by:
ChunkyPNG
Included in:
ChunkyPNG
Defined in:
lib/chunky_png.rb,
lib/chunky_png/chunk.rb,
lib/chunky_png/image.rb,
lib/chunky_png/pixel.rb,
lib/chunky_png/palette.rb,
lib/chunky_png/datastream.rb,
lib/chunky_png/pixel_matrix.rb,
lib/chunky_png/pixel_matrix/decoding.rb,
lib/chunky_png/pixel_matrix/encoding.rb

Overview

ChunkyPNG

The ChunkyPNG module defines some constants that are used in the PNG specification.

Defined Under Namespace

Classes: Chunk, Datastream, Image, Palette, Pixel, PixelMatrix

Constant Summary collapse

COLOR_GRAYSCALE =

PNG international standard defined constants

0
COLOR_TRUECOLOR =
2
COLOR_INDEXED =
3
COLOR_GRAYSCALE_ALPHA =
4
COLOR_TRUECOLOR_ALPHA =
6
FILTERING_DEFAULT =
0
COMPRESSION_DEFAULT =
0
INTERLACING_NONE =
0
INTERLACING_ADAM7 =
1
FILTER_NONE =
0
FILTER_SUB =
1
FILTER_UP =
2
FILTER_AVERAGE =
3
FILTER_PAETH =
4

Instance Method Summary collapse

Instance Method Details

#load(arg) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/chunky_png.rb', line 55

def load(arg)
  if arg.respond_to?(:read)
    load_from_io(arg)
  elsif File.exists?(arg)
    load_from_file(arg)
  else
    load_from_memory(arg)
  end
end

#load_from_file(file) ⇒ Object



47
48
49
# File 'lib/chunky_png.rb', line 47

def load_from_file(file)
  File.open(file, 'r') { |f| load_from_io(f) }
end

#load_from_io(io) ⇒ Object



43
44
45
# File 'lib/chunky_png.rb', line 43

def load_from_io(io)
  ChunkyPNG::Datastream.read(io)
end

#load_from_memory(string) ⇒ Object



51
52
53
# File 'lib/chunky_png.rb', line 51

def load_from_memory(string)
  load_from_io(StringIO.new(string))
end