You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EncodingOptions.cs 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright 2012 ZXing.Net 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. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. namespace ZXing.Common
  20. {
  21. /// <summary>
  22. /// Defines an container for encoder options
  23. /// </summary>
  24. [Serializable]
  25. public class EncodingOptions
  26. {
  27. /// <summary>
  28. /// Gets the data container for all options
  29. /// </summary>
  30. [Browsable(false)]
  31. public IDictionary<EncodeHintType, object> Hints { get; private set; }
  32. /// <summary>
  33. /// Specifies the height of the barcode image
  34. /// </summary>
  35. public int Height
  36. {
  37. get
  38. {
  39. if (Hints.ContainsKey(EncodeHintType.HEIGHT))
  40. {
  41. return (int)Hints[EncodeHintType.HEIGHT];
  42. }
  43. return 0;
  44. }
  45. set
  46. {
  47. Hints[EncodeHintType.HEIGHT] = value;
  48. }
  49. }
  50. /// <summary>
  51. /// Specifies the width of the barcode image
  52. /// </summary>
  53. public int Width
  54. {
  55. get
  56. {
  57. if (Hints.ContainsKey(EncodeHintType.WIDTH))
  58. {
  59. return (int)Hints[EncodeHintType.WIDTH];
  60. }
  61. return 0;
  62. }
  63. set
  64. {
  65. Hints[EncodeHintType.WIDTH] = value;
  66. }
  67. }
  68. /// <summary>
  69. /// Don't put the content string into the output image.
  70. /// </summary>
  71. public bool PureBarcode
  72. {
  73. get
  74. {
  75. if (Hints.ContainsKey(EncodeHintType.PURE_BARCODE))
  76. {
  77. return (bool)Hints[EncodeHintType.PURE_BARCODE];
  78. }
  79. return false;
  80. }
  81. set
  82. {
  83. Hints[EncodeHintType.PURE_BARCODE] = value;
  84. }
  85. }
  86. /// <summary>
  87. /// Specifies margin, in pixels, to use when generating the barcode. The meaning can vary
  88. /// by format; for example it controls margin before and after the barcode horizontally for
  89. /// most 1D formats.
  90. /// </summary>
  91. public int Margin
  92. {
  93. get
  94. {
  95. if (Hints.ContainsKey(EncodeHintType.MARGIN))
  96. {
  97. return (int) Hints[EncodeHintType.MARGIN];
  98. }
  99. return 0;
  100. }
  101. set
  102. {
  103. Hints[EncodeHintType.MARGIN] = value;
  104. }
  105. }
  106. /// <summary>
  107. /// Initializes a new instance of the <see cref="EncodingOptions"/> class.
  108. /// </summary>
  109. public EncodingOptions()
  110. {
  111. Hints = new Dictionary<EncodeHintType, object>();
  112. }
  113. }
  114. }