-/*\r
+/*\r
* Copyright 2008 ZXing authors\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
+using System;\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 ByteArray\r
- {\r
- private static int INITIAL_SIZE = 32;\r
- private sbyte[] bytes;\r
- private int Size;\r
-\r
- public ByteArray()\r
- {\r
- bytes = null;\r
- this.Size = 0;\r
- }\r
-\r
- public ByteArray(int size)\r
- {\r
- bytes = new sbyte[size];\r
- this.Size = size;\r
- }\r
-\r
- public ByteArray(sbyte[] byteArray)\r
- {\r
- bytes = byteArray;\r
- this.Size = bytes.Length;\r
- }\r
-\r
- /**\r
- * Access an unsigned byte at location index.\r
- * @param index The index in the array to access.\r
- * @return The unsigned value of the byte as an int.\r
- */\r
- public int at(int index)\r
- {\r
- return bytes[index] & 0xff;\r
- }\r
-\r
- public void set(int index, int value)\r
- {\r
- bytes[index] = (sbyte)value;\r
- }\r
-\r
- public int size()\r
- {\r
- return Size;\r
- }\r
-\r
- public bool empty()\r
- {\r
- return Size == 0;\r
- }\r
-\r
- public void appendByte(int value)\r
- {\r
- if (Size == 0 || Size >= bytes.Length)\r
- {\r
- int newSize = Math.Max(INITIAL_SIZE, Size << 1);\r
- reserve(newSize);\r
- }\r
- bytes[Size] = (sbyte)value;\r
- Size++;\r
- }\r
-\r
- public void reserve(int capacity)\r
- {\r
- if (bytes == null || bytes.Length < capacity)\r
- {\r
- sbyte[] newArray = new sbyte[capacity];\r
- if (bytes != null)\r
- {\r
- System.Array.Copy(bytes, 0, newArray, 0, bytes.Length);\r
- }\r
- bytes = newArray;\r
- }\r
- }\r
-\r
- // Copy count bytes from array source starting at offset.\r
- public void set(sbyte[] source, int offset, int count)\r
- {\r
- bytes = new sbyte[count];\r
- Size = count;\r
- for (int x = 0; x < count; x++)\r
- {\r
- bytes[x] = source[offset + x];\r
- }\r
- }\r
- }\r
+ \r
+ /// <summary> This class implements an array of unsigned bytes.\r
+ /// \r
+ /// </summary>\r
+ /// <author> dswitkin@google.com (Daniel Switkin)\r
+ /// </author>\r
+ /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+ /// </author>\r
+ public sealed class ByteArray\r
+ {\r
+ public bool Empty\r
+ {\r
+ get\r
+ {\r
+ return size_Renamed_Field == 0;\r
+ }\r
+ \r
+ }\r
+ \r
+ private const int INITIAL_SIZE = 32;\r
+ \r
+ private sbyte[] bytes;\r
+ private int size_Renamed_Field;\r
+ \r
+ public ByteArray()\r
+ {\r
+ bytes = null;\r
+ size_Renamed_Field = 0;\r
+ }\r
+ \r
+ public ByteArray(int size)\r
+ {\r
+ bytes = new sbyte[size];\r
+ this.size_Renamed_Field = size;\r
+ }\r
+ \r
+ public ByteArray(sbyte[] byteArray)\r
+ {\r
+ bytes = byteArray;\r
+ size_Renamed_Field = bytes.Length;\r
+ }\r
+ \r
+ /// <summary> Access an unsigned byte at location index.</summary>\r
+ /// <param name="index">The index in the array to access.\r
+ /// </param>\r
+ /// <returns> The unsigned value of the byte as an int.\r
+ /// </returns>\r
+ public int at(int index)\r
+ {\r
+ return bytes[index] & 0xff;\r
+ }\r
+ \r
+ public void set_Renamed(int index, int value_Renamed)\r
+ {\r
+ bytes[index] = (sbyte) value_Renamed;\r
+ }\r
+ \r
+ public int size()\r
+ {\r
+ return size_Renamed_Field;\r
+ }\r
+ \r
+ public void appendByte(int value_Renamed)\r
+ {\r
+ if (size_Renamed_Field == 0 || size_Renamed_Field >= bytes.Length)\r
+ {\r
+ int newSize = System.Math.Max(INITIAL_SIZE, size_Renamed_Field << 1);\r
+ reserve(newSize);\r
+ }\r
+ bytes[size_Renamed_Field] = (sbyte) value_Renamed;\r
+ size_Renamed_Field++;\r
+ }\r
+ \r
+ public void reserve(int capacity)\r
+ {\r
+ if (bytes == null || bytes.Length < capacity)\r
+ {\r
+ sbyte[] newArray = new sbyte[capacity];\r
+ if (bytes != null)\r
+ {\r
+ Array.Copy(bytes, 0, newArray, 0, bytes.Length);\r
+ }\r
+ bytes = newArray;\r
+ }\r
+ }\r
+ \r
+ // Copy count bytes from array source starting at offset.\r
+ public void set_Renamed(sbyte[] source, int offset, int count)\r
+ {\r
+ bytes = new sbyte[count];\r
+ size_Renamed_Field = count;\r
+ for (int x = 0; x < count; x++)\r
+ {\r
+ bytes[x] = source[offset + x];\r
+ }\r
+ }\r
+ }\r
}
\ No newline at end of file