Class: ZXing::FFI::Binarizer
- Inherits:
-
Object
- Object
- ZXing::FFI::Binarizer
show all
- Includes:
- Binarizer
- Defined in:
- lib/zxing/ffi/binarizer.rb
Instance Attribute Summary collapse
Attributes included from Binarizer
#native
Instance Method Summary
collapse
Constructor Details
#initialize(ptr, source) ⇒ Binarizer
6
7
8
9
|
# File 'lib/zxing/ffi/binarizer.rb', line 6
def initialize ptr, source
super ZXing::FFI::Library::BinarizerPointer.new ptr
@source = source
end
|
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
10
11
12
|
# File 'lib/zxing/ffi/binarizer.rb', line 10
def source
@source
end
|
Instance Method Details
#black_matrix ⇒ Object
11
12
13
|
# File 'lib/zxing/ffi/binarizer.rb', line 11
def black_matrix
ZXing::FFI::Common::BitMatrix.new ZXing::FFI::Library.Binarizer_black_matrix(native)
end
|
#image ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/zxing/ffi/binarizer.rb', line 14
def image
width = source.width
height = source.height
image = Magick::Image.new width, height
(0...height).each do |row|
(0...width).each do |column|
image.pixel_color(column, row, black_matrix.get(column, row) ? "black" : "white")
end
end
return image
end
|