Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp

Issue 2048983002: Get rid of NULLs in xfa/fxbarcode/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp ('k') | xfa/fxbarcode/qrcode/BC_QRCoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return FALSE; 50 return FALSE;
51 } 51 }
52 m_iCorrectLevel = level; 52 m_iCorrectLevel = level;
53 return TRUE; 53 return TRUE;
54 } 54 }
55 uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, 55 uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents,
56 int32_t ecLevel, 56 int32_t ecLevel,
57 int32_t& outWidth, 57 int32_t& outWidth,
58 int32_t& outHeight, 58 int32_t& outHeight,
59 int32_t& e) { 59 int32_t& e) {
60 CBC_QRCoderErrorCorrectionLevel* ec = NULL; 60 CBC_QRCoderErrorCorrectionLevel* ec = nullptr;
61 switch (ecLevel) { 61 switch (ecLevel) {
62 case 0: 62 case 0:
63 ec = CBC_QRCoderErrorCorrectionLevel::L; 63 ec = CBC_QRCoderErrorCorrectionLevel::L;
64 break; 64 break;
65 case 1: 65 case 1:
66 ec = CBC_QRCoderErrorCorrectionLevel::M; 66 ec = CBC_QRCoderErrorCorrectionLevel::M;
67 break; 67 break;
68 case 2: 68 case 2:
69 ec = CBC_QRCoderErrorCorrectionLevel::Q; 69 ec = CBC_QRCoderErrorCorrectionLevel::Q;
70 break; 70 break;
71 case 3: 71 case 3:
72 ec = CBC_QRCoderErrorCorrectionLevel::H; 72 ec = CBC_QRCoderErrorCorrectionLevel::H;
73 break; 73 break;
74 default: { 74 default: {
75 e = BCExceptionUnSupportEclevel; 75 e = BCExceptionUnSupportEclevel;
76 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 76 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
77 } 77 }
78 } 78 }
79 CBC_QRCoder qr; 79 CBC_QRCoder qr;
80 if (m_iVersion > 0 && m_iVersion < 41) { 80 if (m_iVersion > 0 && m_iVersion < 41) {
81 CFX_ByteString byteStr = contents.UTF8Encode(); 81 CFX_ByteString byteStr = contents.UTF8Encode();
82 CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion); 82 CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion);
83 } else { 83 } else {
84 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); 84 CBC_QRCoderEncoder::Encode(contents, ec, &qr, e);
85 } 85 }
86 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 86 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
87 outWidth = qr.GetMatrixWidth(); 87 outWidth = qr.GetMatrixWidth();
88 outHeight = qr.GetMatrixWidth(); 88 outHeight = qr.GetMatrixWidth();
89 uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); 89 uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight);
90 FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); 90 FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight);
91 return result; 91 return result;
92 } 92 }
93 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, 93 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents,
94 BCFORMAT format, 94 BCFORMAT format,
95 int32_t& outWidth, 95 int32_t& outWidth,
96 int32_t& outHeight, 96 int32_t& outHeight,
97 int32_t hints, 97 int32_t hints,
98 int32_t& e) { 98 int32_t& e) {
99 return NULL; 99 return nullptr;
100 } 100 }
101 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, 101 uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents,
102 BCFORMAT format, 102 BCFORMAT format,
103 int32_t& outWidth, 103 int32_t& outWidth,
104 int32_t& outHeight, 104 int32_t& outHeight,
105 int32_t& e) { 105 int32_t& e) {
106 return NULL; 106 return nullptr;
107 } 107 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp ('k') | xfa/fxbarcode/qrcode/BC_QRCoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698