Class: ZXing::FFI::Binarizer
- Inherits:
-
Object
- Object
- ZXing::FFI::Binarizer
- Includes:
- Binarizer
- Defined in:
- lib/zxing/ffi/binarizer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Attributes included from Binarizer
Instance Method Summary collapse
- #black_matrix ⇒ Object
- #image ⇒ Object
-
#initialize(ptr, source) ⇒ Binarizer
constructor
A new instance of Binarizer.
Constructor Details
#initialize(ptr, source) ⇒ Binarizer
Returns a new instance of 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 (readonly)
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 |