Korean translation from Chang Hyun Park
[zxing.git] / csharp / Binarizer.cs
1 /*\r
2 * Copyright 2009 ZXing authors\r
3 *\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
7 *\r
8 *      http://www.apache.org/licenses/LICENSE-2.0\r
9 *\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
15 */\r
16 using System;\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
20 {\r
21         \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
26         /// \r
27         /// </summary>\r
28         /// <author>  dswitkin@google.com (Daniel Switkin)\r
29         /// </author>\r
30         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
31         /// </author>\r
32 \r
33         public abstract class Binarizer\r
34         {\r
35                 virtual public LuminanceSource LuminanceSource\r
36                 {\r
37                         get\r
38                         {\r
39                                 return source;\r
40                         }\r
41                         \r
42                 }\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
47                 /// \r
48                 /// </summary>\r
49                 /// <returns> The 2D array of bits for the image (true means black).\r
50                 /// </returns>\r
51                 public abstract BitMatrix BlackMatrix{get;}\r
52                 \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
55                 \r
56                 protected internal Binarizer(LuminanceSource source)\r
57                 {\r
58                         if (source == null)\r
59                         {\r
60                                 throw new System.ArgumentException("Source must be non-null.");\r
61                         }\r
62                         this.source = source;\r
63                 }\r
64                 \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
71                 /// \r
72                 /// </summary>\r
73                 /// <param name="y">The row to fetch, 0 <= y < bitmap height.\r
74                 /// </param>\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
77                 /// </param>\r
78                 /// <returns> The array of bits for this row (true means black).\r
79                 /// </returns>\r
80                 public abstract BitArray getBlackRow(int y, BitArray row);\r
81                 \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
85                 /// \r
86                 /// </summary>\r
87                 /// <param name="source">The LuminanceSource this Binarizer will operate on.\r
88                 /// </param>\r
89                 /// <returns> A new concrete Binarizer implementation object.\r
90                 /// </returns>\r
91                 public abstract Binarizer createBinarizer(LuminanceSource source);\r
92         }\r
93 }