2 * Copyright 2009 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 using BitArray = com.google.zxing.common.BitArray;
\r
18 using BitMatrix = com.google.zxing.common.BitMatrix;
\r
19 namespace com.google.zxing
\r
22 /// <summary> This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
\r
23 /// It allows the algorithm to vary polymorphically, for example allowing a very expensive
\r
24 /// thresholding technique for servers and a fast one for mobile. It also permits the implementation
\r
25 /// to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
\r
28 /// <author> dswitkin@google.com (Daniel Switkin)
\r
30 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
33 public abstract class Binarizer
\r
35 virtual public LuminanceSource LuminanceSource
\r
43 /// <summary> Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
\r
44 /// and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
\r
45 /// may not apply sharpening. Therefore, a row from this matrix may not be identical to one
\r
46 /// fetched using getBlackRow(), so don't mix and match between them.
\r
49 /// <returns> The 2D array of bits for the image (true means black).
\r
51 public abstract BitMatrix BlackMatrix{get;}
\r
53 //UPGRADE_NOTE: Final was removed from the declaration of 'source '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
54 private LuminanceSource source;
\r
56 protected internal Binarizer(LuminanceSource source)
\r
60 throw new System.ArgumentException("Source must be non-null.");
\r
62 this.source = source;
\r
65 /// <summary> Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
\r
66 /// cached data. Callers should assume this method is expensive and call it as seldom as possible.
\r
67 /// This method is intended for decoding 1D barcodes and may choose to apply sharpening.
\r
68 /// For callers which only examine one row of pixels at a time, the same BitArray should be reused
\r
69 /// and passed in with each call for performance. However it is legal to keep more than one row
\r
70 /// at a time if needed.
\r
73 /// <param name="y">The row to fetch, 0 <= y < bitmap height.
\r
75 /// <param name="row">An optional preallocated array. If null or too small, it will be ignored.
\r
76 /// If used, the Binarizer will call BitArray.clear(). Always use the returned object.
\r
78 /// <returns> The array of bits for this row (true means black).
\r
80 public abstract BitArray getBlackRow(int y, BitArray row);
\r
82 /// <summary> Creates a new object with the same type as this Binarizer implementation, but with pristine
\r
83 /// state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
\r
84 /// of 1 bit data. See Effective Java for why we can't use Java's clone() method.
\r
87 /// <param name="source">The LuminanceSource this Binarizer will operate on.
\r
89 /// <returns> A new concrete Binarizer implementation object.
\r
91 public abstract Binarizer createBinarizer(LuminanceSource source);
\r