OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(matrix); | 628 penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(matrix); |
629 penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(matrix); | 629 penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(matrix); |
630 return penalty; | 630 return penalty; |
631 } | 631 } |
632 | 632 |
633 CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, | 633 CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, |
634 CFX_ByteString encoding) { | 634 CFX_ByteString encoding) { |
635 if (encoding.Compare("SHIFT_JIS") == 0) { | 635 if (encoding.Compare("SHIFT_JIS") == 0) { |
636 return CBC_QRCoderMode::sKANJI; | 636 return CBC_QRCoderMode::sKANJI; |
637 } | 637 } |
638 FX_BOOL hasNumeric = FALSE; | 638 bool hasNumeric = false; |
639 FX_BOOL hasAlphaNumeric = FALSE; | 639 bool hasAlphaNumeric = false; |
640 for (int32_t i = 0; i < content.GetLength(); i++) { | 640 for (int32_t i = 0; i < content.GetLength(); i++) { |
641 if (isdigit((uint8_t)content[i])) { | 641 if (isdigit((uint8_t)content[i])) { |
642 hasNumeric = TRUE; | 642 hasNumeric = true; |
643 } else if (GetAlphaNumericCode((uint8_t)content[i]) != -1) { | 643 } else if (GetAlphaNumericCode((uint8_t)content[i]) != -1) { |
644 hasAlphaNumeric = TRUE; | 644 hasAlphaNumeric = true; |
645 } else { | 645 } else { |
646 return CBC_QRCoderMode::sBYTE; | 646 return CBC_QRCoderMode::sBYTE; |
647 } | 647 } |
648 } | 648 } |
649 if (hasAlphaNumeric) { | 649 if (hasAlphaNumeric) { |
650 return CBC_QRCoderMode::sALPHANUMERIC; | 650 return CBC_QRCoderMode::sALPHANUMERIC; |
651 } else if (hasNumeric) { | 651 } else if (hasNumeric) { |
652 return CBC_QRCoderMode::sNUMERIC; | 652 return CBC_QRCoderMode::sNUMERIC; |
653 } | 653 } |
654 return CBC_QRCoderMode::sBYTE; | 654 return CBC_QRCoderMode::sBYTE; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField); | 962 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField); |
963 encode.Init(); | 963 encode.Init(); |
964 encode.Encode(&toEncode, numEcBytesInBlock, e); | 964 encode.Encode(&toEncode, numEcBytesInBlock, e); |
965 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); | 965 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
966 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); | 966 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); |
967 for (int32_t j = 0; j < numEcBytesInBlock; j++) { | 967 for (int32_t j = 0; j < numEcBytesInBlock; j++) { |
968 ecBytes->Set(j, toEncode[numDataBytes + j]); | 968 ecBytes->Set(j, toEncode[numDataBytes + j]); |
969 } | 969 } |
970 return ecBytes; | 970 return ecBytes; |
971 } | 971 } |
OLD | NEW |