| 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 24 matching lines...) Expand all Loading... |
| 35 m_iCorrectLevel = 1; | 35 m_iCorrectLevel = 1; |
| 36 m_iVersion = 0; | 36 m_iVersion = 0; |
| 37 } | 37 } |
| 38 CBC_QRCodeWriter::~CBC_QRCodeWriter() | 38 CBC_QRCodeWriter::~CBC_QRCodeWriter() |
| 39 { | 39 { |
| 40 } | 40 } |
| 41 void CBC_QRCodeWriter::ReleaseAll() | 41 void CBC_QRCodeWriter::ReleaseAll() |
| 42 { | 42 { |
| 43 CBC_QRCodeReader::ReleaseAll(); | 43 CBC_QRCodeReader::ReleaseAll(); |
| 44 } | 44 } |
| 45 FX_BOOL CBC_QRCodeWriter::SetVersion(FX_INT32 version) | 45 FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) |
| 46 { | 46 { |
| 47 if (version < 0 || version > 40) { | 47 if (version < 0 || version > 40) { |
| 48 return FALSE; | 48 return FALSE; |
| 49 } | 49 } |
| 50 m_iVersion = version; | 50 m_iVersion = version; |
| 51 return TRUE; | 51 return TRUE; |
| 52 } | 52 } |
| 53 FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(FX_INT32 level) | 53 FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(int32_t level) |
| 54 { | 54 { |
| 55 if (level < 0 || level > 3) { | 55 if (level < 0 || level > 3) { |
| 56 return FALSE; | 56 return FALSE; |
| 57 } | 57 } |
| 58 m_iCorrectLevel = level; | 58 m_iCorrectLevel = level; |
| 59 return TRUE; | 59 return TRUE; |
| 60 } | 60 } |
| 61 FX_BYTE* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, FX_INT32 ecLev
el, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 &e) | 61 uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, int32_t ecLeve
l, int32_t &outWidth, int32_t &outHeight, int32_t &e) |
| 62 { | 62 { |
| 63 CBC_QRCoderErrorCorrectionLevel *ec = NULL; | 63 CBC_QRCoderErrorCorrectionLevel *ec = NULL; |
| 64 switch(ecLevel) { | 64 switch(ecLevel) { |
| 65 case 0: | 65 case 0: |
| 66 ec = CBC_QRCoderErrorCorrectionLevel::L; | 66 ec = CBC_QRCoderErrorCorrectionLevel::L; |
| 67 break; | 67 break; |
| 68 case 1: | 68 case 1: |
| 69 ec = CBC_QRCoderErrorCorrectionLevel::M; | 69 ec = CBC_QRCoderErrorCorrectionLevel::M; |
| 70 break; | 70 break; |
| 71 case 2: | 71 case 2: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 82 CBC_QRCoder qr; | 82 CBC_QRCoder qr; |
| 83 if (m_iVersion > 0 && m_iVersion < 41) { | 83 if (m_iVersion > 0 && m_iVersion < 41) { |
| 84 CFX_ByteString byteStr = contents.UTF8Encode(); | 84 CFX_ByteString byteStr = contents.UTF8Encode(); |
| 85 CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion); | 85 CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion); |
| 86 } else { | 86 } else { |
| 87 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); | 87 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); |
| 88 } | 88 } |
| 89 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 89 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 90 outWidth = qr.GetMatrixWidth(); | 90 outWidth = qr.GetMatrixWidth(); |
| 91 outHeight = qr.GetMatrixWidth(); | 91 outHeight = qr.GetMatrixWidth(); |
| 92 FX_BYTE* result = FX_Alloc(FX_BYTE, outWidth * outWidth); | 92 uint8_t* result = FX_Alloc(uint8_t, outWidth * outWidth); |
| 93 FXSYS_memcpy32(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); | 93 FXSYS_memcpy32(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); |
| 94 return result; | 94 return result; |
| 95 } | 95 } |
| 96 FX_BYTE *CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, BCFORMAT forma
t, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 hints, FX_INT32 &e) | 96 uint8_t *CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, BCFORMAT forma
t, int32_t &outWidth, int32_t &outHeight, int32_t hints, int32_t &e) |
| 97 { | 97 { |
| 98 return NULL; | 98 return NULL; |
| 99 } | 99 } |
| 100 FX_BYTE* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, BCFORMAT forma
t, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 &e) | 100 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, BCFORMAT forma
t, int32_t &outWidth, int32_t &outHeight, int32_t &e) |
| 101 { | 101 { |
| 102 return NULL; | 102 return NULL; |
| 103 } | 103 } |
| OLD | NEW |