X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=csharp%2Fcommon%2FByteArray.cs;h=ada385dc1660131debd20174f7988785d09b39db;hb=fa9bfee1b50468fdced440e323c6ffe7cb53b12e;hp=5c4d828e2671e6c65ddc0e84f8bef43f5fbff2a6;hpb=e35d358134873c3f640672da7cd0c01f02253151;p=zxing.git
diff --git a/csharp/common/ByteArray.cs b/csharp/common/ByteArray.cs
index 5c4d828e..ada385dc 100755
--- a/csharp/common/ByteArray.cs
+++ b/csharp/common/ByteArray.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,105 +13,104 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+using System;
namespace com.google.zxing.common
{
- using System;
- using System.Text;
-
- /// A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a
- /// unsigned container, it's up to you to do byteValue & 0xff at each location.
- /// *
- /// JAVAPORT: I'm not happy about the argument ordering throughout the file, as I always like to have
- /// the horizontal component first, but this is for compatibility with the C++ code. The original
- /// code was a 2D array of ints, but since it only ever gets assigned -1, 0, and 1, I'm going to use
- /// less memory and go with bytes.
- /// *
- ///
- /// dswitkin@google.com (Daniel Switkin)
- ///
- ///
- public sealed class ByteArray
- {
- private static int INITIAL_SIZE = 32;
- private sbyte[] bytes;
- private int Size;
-
- public ByteArray()
- {
- bytes = null;
- this.Size = 0;
- }
-
- public ByteArray(int size)
- {
- bytes = new sbyte[size];
- this.Size = size;
- }
-
- public ByteArray(sbyte[] byteArray)
- {
- bytes = byteArray;
- this.Size = bytes.Length;
- }
-
- /**
- * Access an unsigned byte at location index.
- * @param index The index in the array to access.
- * @return The unsigned value of the byte as an int.
- */
- public int at(int index)
- {
- return bytes[index] & 0xff;
- }
-
- public void set(int index, int value)
- {
- bytes[index] = (sbyte)value;
- }
-
- public int size()
- {
- return Size;
- }
-
- public bool empty()
- {
- return Size == 0;
- }
-
- public void appendByte(int value)
- {
- if (Size == 0 || Size >= bytes.Length)
- {
- int newSize = Math.Max(INITIAL_SIZE, Size << 1);
- reserve(newSize);
- }
- bytes[Size] = (sbyte)value;
- Size++;
- }
-
- public void reserve(int capacity)
- {
- if (bytes == null || bytes.Length < capacity)
- {
- sbyte[] newArray = new sbyte[capacity];
- if (bytes != null)
- {
- System.Array.Copy(bytes, 0, newArray, 0, bytes.Length);
- }
- bytes = newArray;
- }
- }
-
- // Copy count bytes from array source starting at offset.
- public void set(sbyte[] source, int offset, int count)
- {
- bytes = new sbyte[count];
- Size = count;
- for (int x = 0; x < count; x++)
- {
- bytes[x] = source[offset + x];
- }
- }
- }
+
+ /// This class implements an array of unsigned bytes.
+ ///
+ ///
+ /// dswitkin@google.com (Daniel Switkin)
+ ///
+ /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
+ ///
+ public sealed class ByteArray
+ {
+ public bool Empty
+ {
+ get
+ {
+ return size_Renamed_Field == 0;
+ }
+
+ }
+
+ private const int INITIAL_SIZE = 32;
+
+ private sbyte[] bytes;
+ private int size_Renamed_Field;
+
+ public ByteArray()
+ {
+ bytes = null;
+ size_Renamed_Field = 0;
+ }
+
+ public ByteArray(int size)
+ {
+ bytes = new sbyte[size];
+ this.size_Renamed_Field = size;
+ }
+
+ public ByteArray(sbyte[] byteArray)
+ {
+ bytes = byteArray;
+ size_Renamed_Field = bytes.Length;
+ }
+
+ /// Access an unsigned byte at location index.
+ /// The index in the array to access.
+ ///
+ /// The unsigned value of the byte as an int.
+ ///
+ public int at(int index)
+ {
+ return bytes[index] & 0xff;
+ }
+
+ public void set_Renamed(int index, int value_Renamed)
+ {
+ bytes[index] = (sbyte) value_Renamed;
+ }
+
+ public int size()
+ {
+ return size_Renamed_Field;
+ }
+
+ public void appendByte(int value_Renamed)
+ {
+ if (size_Renamed_Field == 0 || size_Renamed_Field >= bytes.Length)
+ {
+ int newSize = System.Math.Max(INITIAL_SIZE, size_Renamed_Field << 1);
+ reserve(newSize);
+ }
+ bytes[size_Renamed_Field] = (sbyte) value_Renamed;
+ size_Renamed_Field++;
+ }
+
+ public void reserve(int capacity)
+ {
+ if (bytes == null || bytes.Length < capacity)
+ {
+ sbyte[] newArray = new sbyte[capacity];
+ if (bytes != null)
+ {
+ Array.Copy(bytes, 0, newArray, 0, bytes.Length);
+ }
+ bytes = newArray;
+ }
+ }
+
+ // Copy count bytes from array source starting at offset.
+ public void set_Renamed(sbyte[] source, int offset, int count)
+ {
+ bytes = new sbyte[count];
+ size_Renamed_Field = count;
+ for (int x = 0; x < count; x++)
+ {
+ bytes[x] = source[offset + x];
+ }
+ }
+ }
}
\ No newline at end of file