Class: PalletePNG::Image
- Inherits:
-
Object
- Object
- PalletePNG::Image
- Defined in:
- lib/pallete_png/image.rb
Constant Summary collapse
- NotPNG =
Class.new StandardError
Instance Attribute Summary collapse
- #image ⇒ ChunkyPNG::Image readonly
Instance Method Summary collapse
- #datastream ⇒ ChunkyPNG::Datastream
-
#initialize(image_data) ⇒ Image
constructor
A new instance of Image.
- #pallete_based? ⇒ Boolean
-
#to_truecolor_alpha ⇒ String
The new image data that the color_mode is converted to TRUE COLOR alpha.
- #transparency_chunk? ⇒ Boolean
Constructor Details
#initialize(image_data) ⇒ Image
Returns a new instance of Image.
12 13 14 |
# File 'lib/pallete_png/image.rb', line 12 def initialize(image_data) @image = ChunkyPNG::Image.from_blob(image_data) end |
Instance Attribute Details
#image ⇒ ChunkyPNG::Image (readonly)
8 9 10 |
# File 'lib/pallete_png/image.rb', line 8 def image @image end |
Instance Method Details
#datastream ⇒ ChunkyPNG::Datastream
31 32 33 |
# File 'lib/pallete_png/image.rb', line 31 def datastream @datastream ||= image.to_datastream end |
#pallete_based? ⇒ Boolean
21 22 23 24 |
# File 'lib/pallete_png/image.rb', line 21 def pallete_based? color_mode, _depth = image.palette.best_color_settings color_mode == ChunkyPNG::COLOR_INDEXED end |
#to_truecolor_alpha ⇒ String
Returns The new image data that the color_mode is converted to TRUE COLOR alpha.
17 18 19 |
# File 'lib/pallete_png/image.rb', line 17 def to_truecolor_alpha image.to_blob color_mode: ChunkyPNG::COLOR_TRUECOLOR_ALPHA end |
#transparency_chunk? ⇒ Boolean
26 27 28 |
# File 'lib/pallete_png/image.rb', line 26 def transparency_chunk? !datastream.transparency_chunk.nil? end |