Class: ZXing::FFI::Common::GreyscaleLuminanceSource

Inherits:
LuminanceSource show all
Defined in:
lib/zxing/ffi/common/greyscale_luminance_source.rb

Instance Attribute Summary

Attributes included from LuminanceSource

#native

Instance Method Summary collapse

Methods inherited from LuminanceSource

#height, #matrix, #width

Methods included from LuminanceSource

new

Constructor Details

#initialize(image, left = nil, top = nil, width = nil, height = nil) ⇒ GreyscaleLuminanceSource

Returns a new instance of GreyscaleLuminanceSource.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/zxing/ffi/common/greyscale_luminance_source.rb', line 5

def initialize image, left = nil, top = nil, width = nil, height = nil
  data = image.gray
  data_width = image.width
  data_height = image.height
  left == nil && left = 0
  top == nil && top = 0
  width == nil && width = image.width
  height == nil && height = image.height
  super ZXing::FFI::Library.GreyscaleLuminanceSource_new(
                                                         data,
                                                         data_width,
                                                         data_height,
                                                         left,
                                                         top,
                                                         width,
                                                         height)
end

Instance Method Details

#imageObject



22
23
24
25
26
27
28
29
# File 'lib/zxing/ffi/common/greyscale_luminance_source.rb', line 22

def image
  Magick::Image.constitute(width,
                           height, 
                           "I",
                           matrix.get_array_of_char(0, width*height).map{|v|
                             v << 8
                           })
end