+++ /dev/null
-/*\r
-* Copyright 2008 ZXing authors\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-namespace com.google.zxing.common\r
-{\r
- using System;\r
- using System.Text;\r
-\r
- /// <summary> A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a\r
- /// unsigned container, it's up to you to do byteValue & 0xff at each location.\r
- /// *\r
- /// JAVAPORT: I'm not happy about the argument ordering throughout the file, as I always like to have\r
- /// the horizontal component first, but this is for compatibility with the C++ code. The original\r
- /// code was a 2D array of ints, but since it only ever gets assigned -1, 0, and 1, I'm going to use\r
- /// less memory and go with bytes.\r
- /// *\r
- /// </summary>\r
- /// <author> dswitkin@google.com (Daniel Switkin)\r
- /// \r
- /// </author>\r
- public sealed class ByteMatrix\r
- {\r
- private sbyte[][] bytes;\r
- private int Height;\r
- private int Width;\r
-\r
-\r
- public ByteMatrix(int height, int width) {\r
- bytes = new sbyte[height][];\r
- for (int i = 0; i < height; i++) {\r
- bytes[i] = new sbyte[width];\r
- }\r
- this.Height = height;\r
- this.Width = width;\r
- }\r
-\r
- public int height()\r
- {\r
- return Height;\r
- }\r
-\r
- public int width()\r
- {\r
- return Width;\r
- }\r
-\r
- public sbyte get(int y, int x)\r
- {\r
- return bytes[y][x];\r
- }\r
-\r
- public sbyte[][] getArray()\r
- {\r
- return bytes;\r
- }\r
-\r
- public void set(int y, int x, sbyte value)\r
- {\r
- bytes[y][x] = value;\r
- }\r
-\r
- public void set(int y, int x, int value)\r
- {\r
- bytes[y][x] = (sbyte)value;\r
- }\r
-\r
- public void clear(sbyte value)\r
- {\r
- for (int y = 0; y < Height; ++y)\r
- {\r
- for (int x = 0; x < Width; ++x)\r
- {\r
- bytes[y][x] = value;\r
- }\r
- }\r
- }\r
-\r
- public String toString()\r
- {\r
- StringBuilder result = new StringBuilder();\r
- for (int y = 0; y < Height; ++y)\r
- {\r
- for (int x = 0; x < Width; ++x)\r
- {\r
- switch (bytes[y][x])\r
- {\r
- case 0:\r
- result.Append(" 0");\r
- break;\r
- case 1:\r
- result.Append(" 1");\r
- break;\r
- default:\r
- result.Append(" ");\r
- break;\r
- }\r
- }\r
- result.Append('\n');\r
- }\r
- return result.ToString();\r
- } \r
- }\r
-}
\ No newline at end of file