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

ZXPDF417Codeword.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2013 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 "ZXPDF417Codeword.h"
  17. const int ZX_PDF417_BARCODE_ROW_UNKNOWN = -1;
  18. @implementation ZXPDF417Codeword
  19. - (id)initWithStartX:(int)startX endX:(int)endX bucket:(int)bucket value:(int)value {
  20. self = [super init];
  21. if (self) {
  22. _startX = startX;
  23. _endX = endX;
  24. _bucket = bucket;
  25. _value = value;
  26. _rowNumber = ZX_PDF417_BARCODE_ROW_UNKNOWN;
  27. }
  28. return self;
  29. }
  30. - (BOOL)hasValidRowNumber {
  31. return [self isValidRowNumber:self.rowNumber];
  32. }
  33. - (BOOL)isValidRowNumber:(int)rowNumber {
  34. return rowNumber != ZX_PDF417_BARCODE_ROW_UNKNOWN && self.bucket == (rowNumber % 3) * 3;
  35. }
  36. - (void)setRowNumberAsRowIndicatorColumn {
  37. self.rowNumber = (self.value / 30) * 3 + self.bucket / 3;
  38. }
  39. - (int)width {
  40. return self.endX - self.startX;
  41. }
  42. - (NSString *)description {
  43. return [NSString stringWithFormat:@"%d|%d", self.rowNumber, self.value];
  44. }
  45. @end