ByteArray.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2008 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. using System;
  17. namespace FastReport.Barcode.QRCode
  18. {
  19. /* /// <summary> This class implements an array of unsigned bytes.
  20. ///
  21. /// </summary>
  22. /// <author> dswitkin@google.com (Daniel Switkin)
  23. /// </author>
  24. /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
  25. /// </author>*/
  26. internal sealed class ByteArray
  27. {
  28. public bool Empty
  29. {
  30. get
  31. {
  32. return size_Renamed_Field == 0;
  33. }
  34. }
  35. private const int INITIAL_SIZE = 32;
  36. private sbyte[] bytes;
  37. private int size_Renamed_Field;
  38. public ByteArray()
  39. {
  40. bytes = null;
  41. size_Renamed_Field = 0;
  42. }
  43. public ByteArray(int size)
  44. {
  45. bytes = new sbyte[size];
  46. this.size_Renamed_Field = size;
  47. }
  48. public ByteArray(sbyte[] byteArray)
  49. {
  50. bytes = byteArray;
  51. size_Renamed_Field = bytes.Length;
  52. }
  53. /* /// <summary> Access an unsigned byte at location index.</summary>
  54. /// <param name="index">The index in the array to access.
  55. /// </param>
  56. /// <returns> The unsigned value of the byte as an int.
  57. /// </returns>*/
  58. public int at(int index)
  59. {
  60. unchecked
  61. {
  62. return bytes[index] & 0xff;
  63. }
  64. }
  65. public void set_Renamed(int index, int value_Renamed)
  66. {
  67. unchecked
  68. {
  69. bytes[index] = (sbyte)value_Renamed;
  70. }
  71. }
  72. public int size()
  73. {
  74. return size_Renamed_Field;
  75. }
  76. // Copy count bytes from array source starting at offset.
  77. public void set_Renamed(sbyte[] source, int offset, int count)
  78. {
  79. bytes = new sbyte[count];
  80. size_Renamed_Field = count;
  81. for (int x = 0; x < count; x++)
  82. {
  83. bytes[x] = source[offset + x];
  84. }
  85. }
  86. }
  87. }