ByteMatrix.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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> A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a
  20. /// unsigned container, it's up to you to do byteValue &amp; 0xff at each location.
  21. ///
  22. /// JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
  23. /// -1, 0, and 1, I'm going to use less memory and go with bytes.
  24. ///
  25. /// </summary>
  26. /// <author> dswitkin@google.com (Daniel Switkin)
  27. /// </author>
  28. /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
  29. /// </author>*/
  30. internal sealed class ByteMatrix
  31. {
  32. public int Height
  33. {
  34. get
  35. {
  36. return height;
  37. }
  38. }
  39. public int Width
  40. {
  41. get
  42. {
  43. return width;
  44. }
  45. }
  46. public sbyte[][] Array
  47. {
  48. get
  49. {
  50. return bytes;
  51. }
  52. }
  53. //UPGRADE_NOTE: Final was removed from the declaration of 'bytes '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
  54. private sbyte[][] bytes;
  55. //UPGRADE_NOTE: Final was removed from the declaration of 'width '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
  56. private int width;
  57. //UPGRADE_NOTE: Final was removed from the declaration of 'height '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
  58. private int height;
  59. public ByteMatrix(int width, int height)
  60. {
  61. bytes = new sbyte[height][];
  62. for (int i = 0; i < height; i++)
  63. {
  64. bytes[i] = new sbyte[width];
  65. }
  66. this.width = width;
  67. this.height = height;
  68. }
  69. public sbyte get_Renamed(int x, int y)
  70. {
  71. return bytes[y][x];
  72. }
  73. public void set_Renamed(int x, int y, sbyte value_Renamed)
  74. {
  75. bytes[y][x] = value_Renamed;
  76. }
  77. public void set_Renamed(int x, int y, int value_Renamed)
  78. {
  79. bytes[y][x] = (sbyte) value_Renamed;
  80. }
  81. public void clear(sbyte value_Renamed)
  82. {
  83. for (int y = 0; y < height; ++y)
  84. {
  85. for (int x = 0; x < width; ++x)
  86. {
  87. bytes[y][x] = value_Renamed;
  88. }
  89. }
  90. }
  91. }
  92. }