Module: ChunkyPNG
- Defined in:
- lib/chunky_png.rb,
lib/chunky_png/point.rb,
lib/chunky_png/chunk.rb,
lib/chunky_png/image.rb,
lib/chunky_png/color.rb,
lib/chunky_png/vector.rb,
lib/chunky_png/canvas.rb,
lib/chunky_png/palette.rb,
lib/chunky_png/rmagick.rb,
lib/chunky_png/dimension.rb,
lib/chunky_png/datastream.rb,
lib/chunky_png/canvas/drawing.rb,
lib/chunky_png/canvas/masking.rb,
lib/chunky_png/canvas/operations.rb,
lib/chunky_png/canvas/resampling.rb,
lib/chunky_png/canvas/png_decoding.rb,
lib/chunky_png/canvas/png_encoding.rb,
lib/chunky_png/canvas/stream_exporting.rb,
lib/chunky_png/canvas/stream_importing.rb,
lib/chunky_png/canvas/adam7_interlacing.rb,
lib/chunky_png/canvas/data_url_exporting.rb,
lib/chunky_png/canvas/data_url_importing.rb
Overview
ChunkyPNG - the pure ruby library to access PNG files.
The ChunkyPNG module defines some constants that are used in the PNG specification, specifies some exception classes, and serves as a namespace for all the other modules and classes in this library.
|
class to represent PNG images, including metadata. | |
|
class to represent the image's canvas. | |
|
module to work with color values. | |
|
represents the palette of colors used on a Canvas. | |
|
represents the internal structure of a PNG Image. | |
|
represents one chunk of data within a Datastream. | |
|
geometry helper class representing a 2-dimensional point. | |
|
geometry helper class representing a dimension (i.e. width x height). | |
|
geometry helper class representing a series of points. |
Defined Under Namespace
Modules: Chunk, Color, RMagick Classes: CRCMismatch, Canvas, Datastream, Dimension, Exception, ExpectationFailed, Image, NotSupported, OutOfBounds, Palette, Point, SignatureMismatch, Vector
Constant Summary
- VERSION =
The current version of ChunkyPNG. This value will be updated automatically by them gem:release rake task.
"1.2.8"
Class Method Summary (collapse)
-
+ (Integer) Color(*args)
Factory method to return a color value, based on the arguments given.
-
+ (ChunkyPNG::Dimension) Dimension(*args)
Creates a Dimension instance using arguments that can be interpreted as width and height.
- + (Object) force_binary(str)
-
+ (ChunkyPNG::Point) Point(*args)
Factory method to create Point instances.
-
+ (ChunkyPNG::Vector) Vector(*args)
Factory method for Vector instances.
Class Method Details
+ (Integer) Color(r, g, b, a) + (Integer) Color(r, g, b) + (Integer) Color(hex_value, opacity = nil) + (Integer) Color(color_name, opacity = nil) + (Integer) Color(color_value, opacity = nil)
Factory method to return a color value, based on the arguments given.
29 30 31 32 33 34 35 36 37 |
# File 'lib/chunky_png/color.rb', line 29 def self.Color(*args) case args.length when 1; ChunkyPNG::Color.parse(args.first) when 2; (ChunkyPNG::Color.parse(args.first) & 0xffffff00) | args[1].to_i when 3; ChunkyPNG::Color.rgb(*args) when 4; ChunkyPNG::Color.rgba(*args) else raise ArgumentError, "Don't know how to create a color from #{args.inspect}!" end end |
+ (ChunkyPNG::Dimension) Dimension(width, height) + (ChunkyPNG::Dimension) Dimension(string) + (ChunkyPNG::Dimension) Dimension(ary) + (ChunkyPNG::Dimension) Dimension(hash)
Creates a Dimension instance using arguments that can be interpreted as width and height.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chunky_png/dimension.rb', line 30 def self.Dimension(*args) case args.length when 2; ChunkyPNG::Dimension.new(*args) when 1; case source = args.first when ChunkyPNG::Dimension; source when ChunkyPNG::Point; ChunkyPNG::Dimension.new(source.x, source.y) when Array; ChunkyPNG::Dimension.new(source[0], source[1]) when Hash; ChunkyPNG::Dimension.new(source[:width] || source['width'], source[:height] || source['height']) when ChunkyPNG::Dimension::DIMENSION_REGEXP; ChunkyPNG::Dimension.new($1, $2) else if source.respond_to?(:width) && source.respond_to?(:height) ChunkyPNG::Dimension.new(source.width, source.height) else raise ArgumentError, "Don't know how to construct a point from #{source.inspect}!" end end else raise ArgumentError, "Don't know how to construct a point from #{args.inspect}!" end end |
+ (Object) force_binary(str)
128 129 130 |
# File 'lib/chunky_png.rb', line 128 def self.force_binary(str) str.respond_to?(:force_encoding) ? str.force_encoding('BINARY') : str end |
+ (ChunkyPNG::Point) Point(x, y) + (ChunkyPNG::Point) Point(array) + (ChunkyPNG::Point) Point(hash) + (ChunkyPNG::Point) Point(string)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chunky_png/point.rb', line 31 def self.Point(*args) case args.length when 2; ChunkyPNG::Point.new(*args) when 1; case source = args.first when ChunkyPNG::Point; source when ChunkyPNG::Dimension; ChunkyPNG::Point.new(source.width, source.height) when Array; ChunkyPNG::Point.new(source[0], source[1]) when Hash; ChunkyPNG::Point.new(source[:x] || source['x'], source[:y] || source['y']) when ChunkyPNG::Point::POINT_REGEXP; ChunkyPNG::Point.new($1.to_i, $2.to_i) else if source.respond_to?(:x) && source.respond_to?(:y) ChunkyPNG::Point.new(source.x, source.y) else raise ArgumentError, "Don't know how to construct a point from #{source.inspect}!" end end else raise ArgumentError, "Don't know how to construct a point from #{args.inspect}!" end end |
+ (ChunkyPNG::Vector) Vector(x0, y0, x1, y1, x2, y2, ...) + (ChunkyPNG::Vector) Vector(string) + (ChunkyPNG::Vector) Vector(pointlike, pointlike, pointlike, ...)
Factory method for Vector instances.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chunky_png/vector.rb', line 19 def self.Vector(*args) return args.first if args.length == 1 && args.first.kind_of?(ChunkyPNG::Vector) if args.length == 1 && args.first.respond_to?(:scan) ChunkyPNG::Vector.new(ChunkyPNG::Vector.multiple_from_string(args.first)) # e.g. ['1,1 2,2 3,3'] else ChunkyPNG::Vector.new(ChunkyPNG::Vector.multiple_from_array(args)) # e.g. [[1,1], [2,2], [3,3]] or [1,1,2,2,3,3] end end |