Class: ChunkyPNG::Image
Overview
Image class
Constant Summary collapse
- METADATA_COMPRESSION_TRESHOLD =
300
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Attributes inherited from Canvas
Attributes included from Canvas::PNGDecoding
Attributes included from Canvas::PNGEncoding
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT, metadata = {}) ⇒ Image
constructor
A new instance of Image.
- #initialize_copy(other) ⇒ Object
- #metadata_chunks ⇒ Object
- #to_datastream(constraints = {}) ⇒ Object
Methods inherited from Canvas
#[], #[]=, #eql?, from_canvas, #include?, #palette, #size, #to_image
Methods included from Canvas::PNGDecoding
#decode_png_pixelstream, #from_blob, #from_datastream, #from_file, #from_io
Methods included from Canvas::Adam7Interlacing
#adam7_extract_pass, #adam7_merge_pass, #adam7_multiplier_offset, #adam7_pass_size, #adam7_pass_sizes
Methods included from Canvas::StreamImporting
#from_abgr_stream, #from_bgr_stream, #from_rgb_stream, #from_rgba_stream
Methods included from Canvas::Drawing
Methods included from Canvas::Operations
#change_mask_color!, #change_theme_color!, #compose, #crop, #extract_mask, #replace
Methods included from Canvas::StreamExporting
#to_abgr_stream, #to_rgb_stream, #to_rgba_stream
Methods included from Canvas::PNGEncoding
Constructor Details
#initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT, metadata = {}) ⇒ Image
Returns a new instance of Image.
11 12 13 14 15 |
# File 'lib/chunky_png/image.rb', line 11 def initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT, = {}) super(width, height, initial) @metadata = @metadata_compression_treshhold = 300 end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/chunky_png/image.rb', line 9 def @metadata end |
Class Method Details
.from_datastream(ds) ⇒ Object
38 39 40 41 42 |
# File 'lib/chunky_png/image.rb', line 38 def self.from_datastream(ds) image = super(ds) image. = ds. return image end |
Instance Method Details
#initialize_copy(other) ⇒ Object
17 18 19 20 |
# File 'lib/chunky_png/image.rb', line 17 def initialize_copy(other) super(other) @metdata = other. end |
#metadata_chunks ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/chunky_png/image.rb', line 22 def .map do |key, value| if value.length >= METADATA_COMPRESSION_TRESHOLD ChunkyPNG::Chunk::CompressedText.new(key, value) else ChunkyPNG::Chunk::Text.new(key, value) end end end |
#to_datastream(constraints = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/chunky_png/image.rb', line 32 def to_datastream(constraints = {}) ds = super(constraints) ds.other_chunks += return ds end |