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 17 matching lines...) Expand all Loading... |
28 #include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" | 28 #include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" |
29 #include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" | 29 #include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" |
30 #include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" | 30 #include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" |
31 #include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h" | 31 #include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h" |
32 | 32 |
33 CBC_QRCodeWriter::CBC_QRCodeWriter() { | 33 CBC_QRCodeWriter::CBC_QRCodeWriter() { |
34 m_bFixedSize = TRUE; | 34 m_bFixedSize = TRUE; |
35 m_iCorrectLevel = 1; | 35 m_iCorrectLevel = 1; |
36 m_iVersion = 0; | 36 m_iVersion = 0; |
37 } | 37 } |
| 38 |
38 CBC_QRCodeWriter::~CBC_QRCodeWriter() {} | 39 CBC_QRCodeWriter::~CBC_QRCodeWriter() {} |
| 40 |
39 void CBC_QRCodeWriter::ReleaseAll() { | 41 void CBC_QRCodeWriter::ReleaseAll() { |
40 delete CBC_ReedSolomonGF256::QRCodeFild; | 42 delete CBC_ReedSolomonGF256::QRCodeField; |
41 CBC_ReedSolomonGF256::QRCodeFild = nullptr; | 43 CBC_ReedSolomonGF256::QRCodeField = nullptr; |
42 delete CBC_ReedSolomonGF256::DataMatrixField; | 44 delete CBC_ReedSolomonGF256::DataMatrixField; |
43 CBC_ReedSolomonGF256::DataMatrixField = nullptr; | 45 CBC_ReedSolomonGF256::DataMatrixField = nullptr; |
44 CBC_QRCoderMode::Destroy(); | 46 CBC_QRCoderMode::Destroy(); |
45 CBC_QRCoderErrorCorrectionLevel::Destroy(); | 47 CBC_QRCoderErrorCorrectionLevel::Destroy(); |
46 CBC_QRCoderVersion::Destroy(); | 48 CBC_QRCoderVersion::Destroy(); |
47 } | 49 } |
| 50 |
48 FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) { | 51 FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) { |
49 if (version < 0 || version > 40) { | 52 if (version < 0 || version > 40) { |
50 return FALSE; | 53 return FALSE; |
51 } | 54 } |
52 m_iVersion = version; | 55 m_iVersion = version; |
53 return TRUE; | 56 return TRUE; |
54 } | 57 } |
| 58 |
55 FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(int32_t level) { | 59 FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(int32_t level) { |
56 if (level < 0 || level > 3) { | 60 if (level < 0 || level > 3) { |
57 return FALSE; | 61 return FALSE; |
58 } | 62 } |
59 m_iCorrectLevel = level; | 63 m_iCorrectLevel = level; |
60 return TRUE; | 64 return TRUE; |
61 } | 65 } |
| 66 |
62 uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, | 67 uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, |
63 int32_t ecLevel, | 68 int32_t ecLevel, |
64 int32_t& outWidth, | 69 int32_t& outWidth, |
65 int32_t& outHeight, | 70 int32_t& outHeight, |
66 int32_t& e) { | 71 int32_t& e) { |
67 CBC_QRCoderErrorCorrectionLevel* ec = nullptr; | 72 CBC_QRCoderErrorCorrectionLevel* ec = nullptr; |
68 switch (ecLevel) { | 73 switch (ecLevel) { |
69 case 0: | 74 case 0: |
70 ec = CBC_QRCoderErrorCorrectionLevel::L; | 75 ec = CBC_QRCoderErrorCorrectionLevel::L; |
71 break; | 76 break; |
(...skipping 18 matching lines...) Expand all Loading... |
90 } else { | 95 } else { |
91 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); | 96 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); |
92 } | 97 } |
93 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); | 98 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
94 outWidth = qr.GetMatrixWidth(); | 99 outWidth = qr.GetMatrixWidth(); |
95 outHeight = qr.GetMatrixWidth(); | 100 outHeight = qr.GetMatrixWidth(); |
96 uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); | 101 uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); |
97 FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); | 102 FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); |
98 return result; | 103 return result; |
99 } | 104 } |
| 105 |
100 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, | 106 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, |
101 BCFORMAT format, | 107 BCFORMAT format, |
102 int32_t& outWidth, | 108 int32_t& outWidth, |
103 int32_t& outHeight, | 109 int32_t& outHeight, |
104 int32_t hints, | 110 int32_t hints, |
105 int32_t& e) { | 111 int32_t& e) { |
106 return nullptr; | 112 return nullptr; |
107 } | 113 } |
| 114 |
108 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, | 115 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, |
109 BCFORMAT format, | 116 BCFORMAT format, |
110 int32_t& outWidth, | 117 int32_t& outWidth, |
111 int32_t& outHeight, | 118 int32_t& outHeight, |
112 int32_t& e) { | 119 int32_t& e) { |
113 return nullptr; | 120 return nullptr; |
114 } | 121 } |
OLD | NEW |