您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ZXPDF417BarcodeRow.m 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2012 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. #import "ZXByteArray.h"
  17. #import "ZXPDF417BarcodeRow.h"
  18. @interface ZXPDF417BarcodeRow ()
  19. //A tacker for position in the bar
  20. @property (nonatomic, assign) int currentLocation;
  21. @end
  22. @implementation ZXPDF417BarcodeRow
  23. + (ZXPDF417BarcodeRow *)barcodeRowWithWidth:(int)width {
  24. return [[ZXPDF417BarcodeRow alloc] initWithWidth:width];
  25. }
  26. - (id)initWithWidth:(int)width {
  27. if (self = [super init]) {
  28. _row = [[ZXByteArray alloc] initWithLength:width];
  29. _currentLocation = 0;
  30. }
  31. return self;
  32. }
  33. - (void)setX:(int)x value:(int8_t)value {
  34. self.row.array[x] = value;
  35. }
  36. - (void)setX:(int)x black:(BOOL)black {
  37. self.row.array[x] = (int8_t) (black ? 1 : 0);
  38. }
  39. - (void)addBar:(BOOL)black width:(int)width {
  40. for (int ii = 0; ii < width; ii++) {
  41. [self setX:self.currentLocation++ black:black];
  42. }
  43. }
  44. - (ZXByteArray *)scaledRow:(int)scale {
  45. ZXByteArray *output = [[ZXByteArray alloc] initWithLength:self.row.length * scale];
  46. for (int i = 0; i < output.length; i++) {
  47. output.array[i] = self.row.array[i / scale];
  48. }
  49. return output;
  50. }
  51. @end