| 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 2009 ZXing authors | 8 * Copyright 2009 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 int32_t checksum = (odd * 3 + even) % 10; | 85 int32_t checksum = (odd * 3 + even) % 10; |
| 86 checksum = (10 - checksum) % 10; | 86 checksum = (10 - checksum) % 10; |
| 87 return (checksum); | 87 return (checksum); |
| 88 } | 88 } |
| 89 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, | 89 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, |
| 90 BCFORMAT format, | 90 BCFORMAT format, |
| 91 int32_t& outWidth, | 91 int32_t& outWidth, |
| 92 int32_t& outHeight, | 92 int32_t& outHeight, |
| 93 int32_t& e) { | 93 int32_t& e) { |
| 94 uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); | 94 uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); |
| 95 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 95 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 96 return ret; | 96 return ret; |
| 97 } | 97 } |
| 98 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, | 98 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, |
| 99 BCFORMAT format, | 99 BCFORMAT format, |
| 100 int32_t& outWidth, | 100 int32_t& outWidth, |
| 101 int32_t& outHeight, | 101 int32_t& outHeight, |
| 102 int32_t hints, | 102 int32_t hints, |
| 103 int32_t& e) { | 103 int32_t& e) { |
| 104 if (format != BCFORMAT_EAN_8) { | 104 if (format != BCFORMAT_EAN_8) { |
| 105 e = BCExceptionOnlyEncodeEAN_8; | 105 e = BCExceptionOnlyEncodeEAN_8; |
| 106 return NULL; | 106 return nullptr; |
| 107 } | 107 } |
| 108 uint8_t* ret = | 108 uint8_t* ret = |
| 109 CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); | 109 CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); |
| 110 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 110 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 111 return ret; | 111 return ret; |
| 112 } | 112 } |
| 113 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, | 113 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, |
| 114 int32_t& outLength, | 114 int32_t& outLength, |
| 115 int32_t& e) { | 115 int32_t& e) { |
| 116 if (contents.GetLength() != 8) { | 116 if (contents.GetLength() != 8) { |
| 117 e = BCExceptionDigitLengthMustBe8; | 117 e = BCExceptionDigitLengthMustBe8; |
| 118 return NULL; | 118 return nullptr; |
| 119 } | 119 } |
| 120 outLength = m_codeWidth; | 120 outLength = m_codeWidth; |
| 121 uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); | 121 uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); |
| 122 int32_t pos = 0; | 122 int32_t pos = 0; |
| 123 pos += | 123 pos += |
| 124 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); | 124 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); |
| 125 if (e != BCExceptionNO) { | 125 if (e != BCExceptionNO) { |
| 126 FX_Free(result); | 126 FX_Free(result); |
| 127 return NULL; | 127 return nullptr; |
| 128 } | 128 } |
| 129 int32_t i = 0; | 129 int32_t i = 0; |
| 130 for (i = 0; i <= 3; i++) { | 130 for (i = 0; i <= 3; i++) { |
| 131 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str()); | 131 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str()); |
| 132 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0, | 132 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0, |
| 133 e); | 133 e); |
| 134 if (e != BCExceptionNO) { | 134 if (e != BCExceptionNO) { |
| 135 FX_Free(result); | 135 FX_Free(result); |
| 136 return NULL; | 136 return nullptr; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); | 139 pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); |
| 140 if (e != BCExceptionNO) { | 140 if (e != BCExceptionNO) { |
| 141 FX_Free(result); | 141 FX_Free(result); |
| 142 return NULL; | 142 return nullptr; |
| 143 } | 143 } |
| 144 for (i = 4; i <= 7; i++) { | 144 for (i = 4; i <= 7; i++) { |
| 145 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str()); | 145 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str()); |
| 146 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, | 146 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, |
| 147 e); | 147 e); |
| 148 if (e != BCExceptionNO) { | 148 if (e != BCExceptionNO) { |
| 149 FX_Free(result); | 149 FX_Free(result); |
| 150 return NULL; | 150 return nullptr; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 pos += | 153 pos += |
| 154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); | 154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); |
| 155 if (e != BCExceptionNO) { | 155 if (e != BCExceptionNO) { |
| 156 FX_Free(result); | 156 FX_Free(result); |
| 157 return NULL; | 157 return nullptr; |
| 158 } | 158 } |
| 159 return result; | 159 return result; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, | 162 void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, |
| 163 CFX_DIBitmap* pOutBitmap, | 163 CFX_DIBitmap* pOutBitmap, |
| 164 CFX_RenderDevice* device, | 164 CFX_RenderDevice* device, |
| 165 const CFX_Matrix* matrix, | 165 const CFX_Matrix* matrix, |
| 166 int32_t barWidth, | 166 int32_t barWidth, |
| 167 int32_t multiple, | 167 int32_t multiple, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 FX_Free(pCharPos); | 262 FX_Free(pCharPos); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, | 265 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, |
| 266 uint8_t* code, | 266 uint8_t* code, |
| 267 int32_t codeLength, | 267 int32_t codeLength, |
| 268 FX_BOOL isDevice, | 268 FX_BOOL isDevice, |
| 269 int32_t& e) { | 269 int32_t& e) { |
| 270 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); | 270 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); |
| 271 } | 271 } |
| OLD | NEW |