2 * Copyright 2008 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 namespace com.google.zxing.common
\r
20 /// <summary> A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a
\r
21 /// unsigned container, it's up to you to do byteValue & 0xff at each location.
\r
23 /// JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
\r
24 /// -1, 0, and 1, I'm going to use less memory and go with bytes.
\r
27 /// <author> dswitkin@google.com (Daniel Switkin)
\r
29 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
31 public sealed class ByteMatrix
\r
49 public sbyte[][] Array
\r
58 //UPGRADE_NOTE: Final was removed from the declaration of 'bytes '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
59 private sbyte[][] bytes;
\r
60 //UPGRADE_NOTE: Final was removed from the declaration of 'width '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
62 //UPGRADE_NOTE: Final was removed from the declaration of 'height '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
65 public ByteMatrix(int width, int height)
\r
67 bytes = new sbyte[height][];
\r
68 for (int i = 0; i < height; i++)
\r
70 bytes[i] = new sbyte[width];
\r
73 this.height = height;
\r
76 public sbyte get_Renamed(int x, int y)
\r
81 public void set_Renamed(int x, int y, sbyte value_Renamed)
\r
83 bytes[y][x] = value_Renamed;
\r
86 public void set_Renamed(int x, int y, int value_Renamed)
\r
88 bytes[y][x] = (sbyte) value_Renamed;
\r
91 public void clear(sbyte value_Renamed)
\r
93 for (int y = 0; y < height; ++y)
\r
95 for (int x = 0; x < width; ++x)
\r
97 bytes[y][x] = value_Renamed;
\r
102 public override System.String ToString()
\r
104 System.Text.StringBuilder result = new System.Text.StringBuilder(2 * width * height + 2);
\r
105 for (int y = 0; y < height; ++y)
\r
107 for (int x = 0; x < width; ++x)
\r
109 switch (bytes[y][x])
\r
113 result.Append(" 0");
\r
117 result.Append(" 1");
\r
121 result.Append(" ");
\r
126 result.Append('\n');
\r
128 return result.ToString();
\r