Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
BC_QRCodeWriter.cpp
Go to the documentation of this file.
1
// Copyright 2014 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
// Original code is licensed as follows:
7
/*
8
* Copyright 2008 ZXing authors
9
*
10
* Licensed under the Apache License, Version 2.0 (the "License");
11
* you may not use this file except in compliance with the License.
12
* You may obtain a copy of the License at
13
*
14
* http://www.apache.org/licenses/LICENSE-2.0
15
*
16
* Unless required by applicable law or agreed to in writing, software
17
* distributed under the License is distributed on an "AS IS" BASIS,
18
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
* See the License for the specific language governing permissions and
20
* limitations under the License.
21
*/
22
23
#
include
"fxbarcode/qrcode/BC_QRCodeWriter.h"
24
25
#
include
<
stdint
.
h
>
26
27
#
include
<
memory
>
28
29
#
include
"core/fxcrt/data_vector.h"
30
#
include
"fxbarcode/common/BC_CommonByteMatrix.h"
31
#
include
"fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
32
#
include
"fxbarcode/qrcode/BC_QRCoder.h"
33
#
include
"fxbarcode/qrcode/BC_QRCoderEncoder.h"
34
#
include
"fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
35
#
include
"fxbarcode/qrcode/BC_QRCoderMode.h"
36
#
include
"fxbarcode/qrcode/BC_QRCoderVersion.h"
37
38
CBC_QRCodeWriter::
CBC_QRCodeWriter
() :
CBC_TwoDimWriter
(
true
)
{}
39
40
CBC_QRCodeWriter::~
CBC_QRCodeWriter
() =
default
;
41
42
bool
CBC_QRCodeWriter::
SetErrorCorrectionLevel
(int32_t level) {
43
if
(level < 0 || level > 3) {
44
return
false
;
45
}
46
set_error_correction_level
(level);
47
return
true
;
48
}
49
50
DataVector
<
uint8_t
> CBC_QRCodeWriter::
Encode
(
WideStringView
contents,
51
int32_t ecLevel,
52
int32_t* pOutWidth,
53
int32_t* pOutHeight) {
54
CBC_QRCoderErrorCorrectionLevel
* ec =
nullptr
;
55
switch
(ecLevel) {
56
case
0:
57
ec =
CBC_QRCoderErrorCorrectionLevel
::
L
;
58
break
;
59
case
1:
60
ec =
CBC_QRCoderErrorCorrectionLevel
::
M
;
61
break
;
62
case
2:
63
ec =
CBC_QRCoderErrorCorrectionLevel
::
Q
;
64
break
;
65
case
3:
66
ec =
CBC_QRCoderErrorCorrectionLevel
::
H
;
67
break
;
68
default
:
69
return
DataVector<uint8_t>();
70
}
71
CBC_QRCoder qr;
72
if
(!
CBC_QRCoderEncoder
::
Encode
(
contents
,
ec
,
&qr
)
)
73
return
DataVector<uint8_t>();
74
75
*pOutWidth = qr
.
GetMatrixWidth
(
)
;
76
*pOutHeight = qr
.
GetMatrixWidth
(
)
;
77
std::unique_ptr<CBC_CommonByteMatrix> matrix = qr.TakeMatrix();
78
return
matrix->TakeArray();
79
}
CBC_QRCodeWriter::SetErrorCorrectionLevel
bool SetErrorCorrectionLevel(int32_t level) override
Definition
BC_QRCodeWriter.cpp:42
CBC_QRCodeWriter::~CBC_QRCodeWriter
~CBC_QRCodeWriter() override
CBC_QRCodeWriter::CBC_QRCodeWriter
CBC_QRCodeWriter()
Definition
BC_QRCodeWriter.cpp:38
CBC_QRCodeWriter::Encode
DataVector< uint8_t > Encode(WideStringView contents, int32_t ecLevel, int32_t *pOutWidth, int32_t *pOutHeight)
Definition
BC_QRCodeWriter.cpp:50
CBC_QRCoderEncoder
Definition
BC_QRCoderEncoder.h:15
CBC_QRCoderEncoder::Encode
static bool Encode(WideStringView content, const CBC_QRCoderErrorCorrectionLevel *ecLevel, CBC_QRCoder *qrCode)
Definition
BC_QRCoderEncoder.cpp:372
CBC_QRCoderErrorCorrectionLevel
Definition
BC_QRCoderErrorCorrectionLevel.h:12
CBC_QRCoderErrorCorrectionLevel::Q
static CBC_QRCoderErrorCorrectionLevel * Q
Definition
BC_QRCoderErrorCorrectionLevel.h:16
CBC_QRCoderErrorCorrectionLevel::H
static CBC_QRCoderErrorCorrectionLevel * H
Definition
BC_QRCoderErrorCorrectionLevel.h:17
CBC_QRCoderErrorCorrectionLevel::L
static CBC_QRCoderErrorCorrectionLevel * L
Definition
BC_QRCoderErrorCorrectionLevel.h:14
CBC_QRCoderErrorCorrectionLevel::M
static CBC_QRCoderErrorCorrectionLevel * M
Definition
BC_QRCoderErrorCorrectionLevel.h:15
CBC_QRCoder::GetMatrixWidth
int32_t GetMatrixWidth() const
Definition
BC_QRCoder.cpp:43
CBC_TwoDimWriter
Definition
BC_TwoDimWriter.h:19
CBC_TwoDimWriter::set_error_correction_level
void set_error_correction_level(int32_t level)
Definition
BC_TwoDimWriter.h:32
CBC_TwoDimWriter::CBC_TwoDimWriter
CBC_TwoDimWriter(bool bFixedSize)
Definition
BC_TwoDimWriter.cpp:20
WideStringView
fxcrt::WideStringView WideStringView
Definition
string_view_template.h:326
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
qrcode
BC_QRCodeWriter.cpp
Generated on
for Qt by
1.18.0