Class: Image

Inherits:
Object
  • Object
show all
Defined in:
lib/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelsObject (readonly)

Returns the value of attribute channels.



6
7
8
# File 'lib/image.rb', line 6

def channels
  @channels
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/image.rb', line 6

def data
  @data
end

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/image.rb', line 6

def height
  @height
end

#widthObject (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