| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 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 "barcode.h" | |
| 24 #include "include/BC_QRCoderErrorCorrectionLevel.h" | |
| 25 #include "include/BC_QRCoderMode.h" | |
| 26 #include "include/BC_CommonByteMatrix.h" | |
| 27 #include "include/BC_QRCoder.h" | |
| 28 CBC_QRCoder::CBC_QRCoder() | |
| 29 { | |
| 30 m_mode = NULL; | |
| 31 m_ecLevel = NULL; | |
| 32 m_version = -1; | |
| 33 m_matrixWidth = -1; | |
| 34 m_maskPattern = -1; | |
| 35 m_numTotalBytes = -1; | |
| 36 m_numDataBytes = -1; | |
| 37 m_numECBytes = -1; | |
| 38 m_numRSBlocks = -1; | |
| 39 m_matrix = NULL; | |
| 40 } | |
| 41 CBC_QRCoder::~CBC_QRCoder() | |
| 42 { | |
| 43 if(m_matrix != NULL) { | |
| 44 delete m_matrix; | |
| 45 m_matrix = NULL; | |
| 46 } | |
| 47 m_mode = NULL; | |
| 48 m_ecLevel = NULL; | |
| 49 m_version = -1; | |
| 50 m_matrixWidth = -1; | |
| 51 m_maskPattern = -1; | |
| 52 m_numTotalBytes = -1; | |
| 53 m_numDataBytes = -1; | |
| 54 m_numECBytes = -1; | |
| 55 m_numRSBlocks = -1; | |
| 56 } | |
| 57 CBC_QRCoderMode* CBC_QRCoder::GetMode() | |
| 58 { | |
| 59 return m_mode; | |
| 60 } | |
| 61 CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() | |
| 62 { | |
| 63 return m_ecLevel; | |
| 64 } | |
| 65 FX_INT32 CBC_QRCoder::GetVersion() | |
| 66 { | |
| 67 return m_version; | |
| 68 } | |
| 69 FX_INT32 CBC_QRCoder::GetMatrixWidth() | |
| 70 { | |
| 71 return m_matrixWidth; | |
| 72 } | |
| 73 FX_INT32 CBC_QRCoder::GetMaskPattern() | |
| 74 { | |
| 75 return m_maskPattern; | |
| 76 } | |
| 77 FX_INT32 CBC_QRCoder::GetNumTotalBytes() | |
| 78 { | |
| 79 return m_numTotalBytes; | |
| 80 } | |
| 81 FX_INT32 CBC_QRCoder::GetNumDataBytes() | |
| 82 { | |
| 83 return m_numDataBytes; | |
| 84 } | |
| 85 FX_INT32 CBC_QRCoder::GetNumECBytes() | |
| 86 { | |
| 87 return m_numECBytes; | |
| 88 } | |
| 89 FX_INT32 CBC_QRCoder::GetNumRSBlocks() | |
| 90 { | |
| 91 return m_numRSBlocks; | |
| 92 } | |
| 93 CBC_CommonByteMatrix* CBC_QRCoder::GetMatrix() | |
| 94 { | |
| 95 return m_matrix; | |
| 96 } | |
| 97 FX_INT32 CBC_QRCoder::At(FX_INT32 x, FX_INT32 y, FX_INT32 &e) | |
| 98 { | |
| 99 FX_INT32 value = m_matrix->Get(x, y); | |
| 100 if(!(value == 0 || value == 1)) { | |
| 101 e = BCExceptionValueMustBeEither0or1; | |
| 102 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 103 } | |
| 104 return value; | |
| 105 } | |
| 106 FX_BOOL CBC_QRCoder::IsValid() | |
| 107 { | |
| 108 return | |
| 109 m_mode != NULL && | |
| 110 m_ecLevel != NULL && | |
| 111 m_version != -1 && | |
| 112 m_matrixWidth != -1 && | |
| 113 m_maskPattern != -1 && | |
| 114 m_numTotalBytes != -1 && | |
| 115 m_numDataBytes != -1 && | |
| 116 m_numECBytes != -1 && | |
| 117 m_numRSBlocks != -1 && | |
| 118 IsValidMaskPattern(m_maskPattern) && | |
| 119 m_numTotalBytes == m_numDataBytes + m_numECBytes && | |
| 120 m_matrix != NULL && | |
| 121 m_matrixWidth == m_matrix->GetWidth() && | |
| 122 m_matrix->GetWidth() == m_matrix->GetHeight(); | |
| 123 } | |
| 124 void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) | |
| 125 { | |
| 126 m_mode = value; | |
| 127 } | |
| 128 void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) | |
| 129 { | |
| 130 m_ecLevel = ecLevel; | |
| 131 } | |
| 132 void CBC_QRCoder::SetVersion(FX_INT32 version) | |
| 133 { | |
| 134 m_version = version; | |
| 135 } | |
| 136 void CBC_QRCoder::SetMatrixWidth(FX_INT32 width) | |
| 137 { | |
| 138 m_matrixWidth = width; | |
| 139 } | |
| 140 void CBC_QRCoder::SetMaskPattern(FX_INT32 pattern) | |
| 141 { | |
| 142 m_maskPattern = pattern; | |
| 143 } | |
| 144 void CBC_QRCoder::SetNumDataBytes(FX_INT32 bytes) | |
| 145 { | |
| 146 m_numDataBytes = bytes; | |
| 147 } | |
| 148 void CBC_QRCoder::SetNumTotalBytes(FX_INT32 value) | |
| 149 { | |
| 150 m_numTotalBytes = value; | |
| 151 } | |
| 152 void CBC_QRCoder::SetNumRSBlocks(FX_INT32 block) | |
| 153 { | |
| 154 m_numRSBlocks = block; | |
| 155 } | |
| 156 void CBC_QRCoder::SetNumECBytes(FX_INT32 value) | |
| 157 { | |
| 158 m_numECBytes = value; | |
| 159 } | |
| 160 FX_BOOL CBC_QRCoder::IsValidMaskPattern(FX_INT32 maskPattern) | |
| 161 { | |
| 162 return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; | |
| 163 } | |
| 164 void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) | |
| 165 { | |
| 166 m_matrix = value; | |
| 167 } | |
| 168 const FX_INT32 CBC_QRCoder::NUM_MASK_PATTERNS = 8; | |
| OLD | NEW |