Class: Image
- Inherits:
-
Object
- Object
- Image
- Defined in:
- lib/image.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(path) ⇒ Image
constructor
A new instance of Image.
- #read(path) ⇒ Object
- #write(path) ⇒ Object
Constructor Details
#initialize(path) ⇒ Image
Returns a new instance of Image.
7 8 9 |
# File 'lib/image.rb', line 7 def initialize(path) @data = read(path) end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
6 7 8 |
# File 'lib/image.rb', line 6 def channels @channels end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/image.rb', line 6 def data @data end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/image.rb', line 6 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/image.rb', line 6 def width @width end |
Instance Method Details
#read(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/image.rb', line 11 def read(path) is_bmp = 1 if(is_bmp) bmp_instance = Bmp.new(path) a = bmp_instance.read_to_array bmp_instance.describe @height = bmp_instance.height @width = bmp_instance.width #@channels = a[0][0].length end a end |
#write(path) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/image.rb', line 25 def write(path) is_bmp = true if(is_bmp) a = Bmp.write_to_bmp(path,@data,8,0) end end |