summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp')
-rw-r--r--xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp662
1 files changed, 338 insertions, 324 deletions
diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp
index 4fb82f1034..16275a0c55 100644
--- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp
+++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp
@@ -24,343 +24,357 @@
#include "../common/BC_CommonBitMatrix.h"
#include "BC_DataMatrixVersion.h"
#include "BC_DataMatrixBitMatrixParser.h"
-CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser()
-{
- m_mappingBitMatrix = NULL;
- m_version = NULL;
- m_readMappingMatrix = NULL;
+CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser() {
+ m_mappingBitMatrix = NULL;
+ m_version = NULL;
+ m_readMappingMatrix = NULL;
}
-void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix *bitMatrix, int32_t &e)
-{
- int32_t dimension = bitMatrix->GetHeight();
- if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) {
- e = BCExceptionFormatException;
- return;
- }
- m_version = ReadVersion(bitMatrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- m_mappingBitMatrix = ExtractDataRegion(bitMatrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- m_readMappingMatrix = FX_NEW CBC_CommonBitMatrix();
- m_readMappingMatrix->Init(m_mappingBitMatrix->GetWidth(), m_mappingBitMatrix->GetHeight());
+void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix,
+ int32_t& e) {
+ int32_t dimension = bitMatrix->GetHeight();
+ if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) {
+ e = BCExceptionFormatException;
+ return;
+ }
+ m_version = ReadVersion(bitMatrix, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ m_mappingBitMatrix = ExtractDataRegion(bitMatrix, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ m_readMappingMatrix = FX_NEW CBC_CommonBitMatrix();
+ m_readMappingMatrix->Init(m_mappingBitMatrix->GetWidth(),
+ m_mappingBitMatrix->GetHeight());
}
-CBC_DataMatrixBitMatrixParser::~CBC_DataMatrixBitMatrixParser()
-{
- if(m_mappingBitMatrix != NULL) {
- delete m_mappingBitMatrix;
- }
- m_mappingBitMatrix = NULL;
- if(m_readMappingMatrix != NULL) {
- delete m_readMappingMatrix;
- }
- m_readMappingMatrix = NULL;
+CBC_DataMatrixBitMatrixParser::~CBC_DataMatrixBitMatrixParser() {
+ if (m_mappingBitMatrix != NULL) {
+ delete m_mappingBitMatrix;
+ }
+ m_mappingBitMatrix = NULL;
+ if (m_readMappingMatrix != NULL) {
+ delete m_readMappingMatrix;
+ }
+ m_readMappingMatrix = NULL;
}
-CBC_DataMatrixVersion *CBC_DataMatrixBitMatrixParser::GetVersion()
-{
- return m_version;
+CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::GetVersion() {
+ return m_version;
}
-CBC_DataMatrixVersion *CBC_DataMatrixBitMatrixParser::ReadVersion(CBC_CommonBitMatrix *bitMatrix, int32_t &e)
-{
- int32_t rows = bitMatrix->GetHeight();
- int32_t columns = bitMatrix->GetWidth();
- CBC_DataMatrixVersion *temp = CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
+CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion(
+ CBC_CommonBitMatrix* bitMatrix,
+ int32_t& e) {
+ int32_t rows = bitMatrix->GetHeight();
+ int32_t columns = bitMatrix->GetWidth();
+ CBC_DataMatrixVersion* temp =
+ CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-CFX_ByteArray *CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t &e)
-{
- CBC_AutoPtr<CFX_ByteArray> result(FX_NEW CFX_ByteArray());
- result->SetSize(m_version->GetTotalCodewords());
- int32_t resultOffset = 0;
- int32_t row = 4;
- int32_t column = 0;
- int32_t numRows = m_mappingBitMatrix->GetHeight();
- int32_t numColumns = m_mappingBitMatrix->GetWidth();
- FX_BOOL corner1Read = FALSE;
- FX_BOOL corner2Read = FALSE;
- FX_BOOL corner3Read = FALSE;
- FX_BOOL corner4Read = FALSE;
- do {
- if ((row == numRows) && (column == 0) && !corner1Read) {
- (*result)[resultOffset++] = (uint8_t) ReadCorner1(numRows, numColumns);
- row -= 2;
- column += 2;
- corner1Read = TRUE;
- } else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
- (*result)[resultOffset++] = (uint8_t) ReadCorner2(numRows, numColumns);
- row -= 2;
- column += 2;
- corner2Read = TRUE;
- } else if ((row == numRows + 4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
- (*result)[resultOffset++] = (uint8_t) ReadCorner3(numRows, numColumns);
- row -= 2;
- column += 2;
- corner3Read = TRUE;
- } else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
- (*result)[resultOffset++] = (uint8_t) ReadCorner4(numRows, numColumns);
- row -= 2;
- column += 2;
- corner4Read = TRUE;
- } else {
- do {
- if ((row < numRows) && (column >= 0) && !m_readMappingMatrix->Get(column, row)) {
- if (resultOffset < (*result).GetSize() ) {
- (*result)[resultOffset++] = (uint8_t) ReadUtah(row, column, numRows, numColumns);
- }
- }
- row -= 2;
- column += 2;
- } while ((row >= 0) && (column < numColumns));
- row += 1;
- column += 3;
- do {
- if ((row >= 0) && (column < numColumns) && !m_readMappingMatrix->Get(column, row)) {
- if (resultOffset < (*result).GetSize() ) {
- (*result)[resultOffset++] = (uint8_t) ReadUtah(row, column, numRows, numColumns);
- }
- }
- row += 2;
- column -= 2;
- } while ((row < numRows) && (column >= 0));
- row += 3;
- column += 1;
+CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) {
+ CBC_AutoPtr<CFX_ByteArray> result(FX_NEW CFX_ByteArray());
+ result->SetSize(m_version->GetTotalCodewords());
+ int32_t resultOffset = 0;
+ int32_t row = 4;
+ int32_t column = 0;
+ int32_t numRows = m_mappingBitMatrix->GetHeight();
+ int32_t numColumns = m_mappingBitMatrix->GetWidth();
+ FX_BOOL corner1Read = FALSE;
+ FX_BOOL corner2Read = FALSE;
+ FX_BOOL corner3Read = FALSE;
+ FX_BOOL corner4Read = FALSE;
+ do {
+ if ((row == numRows) && (column == 0) && !corner1Read) {
+ (*result)[resultOffset++] = (uint8_t)ReadCorner1(numRows, numColumns);
+ row -= 2;
+ column += 2;
+ corner1Read = TRUE;
+ } else if ((row == numRows - 2) && (column == 0) &&
+ ((numColumns & 0x03) != 0) && !corner2Read) {
+ (*result)[resultOffset++] = (uint8_t)ReadCorner2(numRows, numColumns);
+ row -= 2;
+ column += 2;
+ corner2Read = TRUE;
+ } else if ((row == numRows + 4) && (column == 2) &&
+ ((numColumns & 0x07) == 0) && !corner3Read) {
+ (*result)[resultOffset++] = (uint8_t)ReadCorner3(numRows, numColumns);
+ row -= 2;
+ column += 2;
+ corner3Read = TRUE;
+ } else if ((row == numRows - 2) && (column == 0) &&
+ ((numColumns & 0x07) == 4) && !corner4Read) {
+ (*result)[resultOffset++] = (uint8_t)ReadCorner4(numRows, numColumns);
+ row -= 2;
+ column += 2;
+ corner4Read = TRUE;
+ } else {
+ do {
+ if ((row < numRows) && (column >= 0) &&
+ !m_readMappingMatrix->Get(column, row)) {
+ if (resultOffset < (*result).GetSize()) {
+ (*result)[resultOffset++] =
+ (uint8_t)ReadUtah(row, column, numRows, numColumns);
+ }
}
- } while ((row < numRows) || (column < numColumns));
- if (resultOffset != m_version->GetTotalCodewords()) {
- e = BCExceptionFormatException;
- return NULL;
- }
- return result.release();
+ row -= 2;
+ column += 2;
+ } while ((row >= 0) && (column < numColumns));
+ row += 1;
+ column += 3;
+ do {
+ if ((row >= 0) && (column < numColumns) &&
+ !m_readMappingMatrix->Get(column, row)) {
+ if (resultOffset < (*result).GetSize()) {
+ (*result)[resultOffset++] =
+ (uint8_t)ReadUtah(row, column, numRows, numColumns);
+ }
+ }
+ row += 2;
+ column -= 2;
+ } while ((row < numRows) && (column >= 0));
+ row += 3;
+ column += 1;
+ }
+ } while ((row < numRows) || (column < numColumns));
+ if (resultOffset != m_version->GetTotalCodewords()) {
+ e = BCExceptionFormatException;
+ return NULL;
+ }
+ return result.release();
}
-FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row, int32_t column, int32_t numRows, int32_t numColumns)
-{
- if (row < 0) {
- row += numRows;
- column += 4 - ((numRows + 4) & 0x07);
- }
- if (column < 0) {
- column += numColumns;
- row += 4 - ((numColumns + 4) & 0x07);
- }
- m_readMappingMatrix->Set(column, row);
- return m_mappingBitMatrix->Get(column, row);
+FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row,
+ int32_t column,
+ int32_t numRows,
+ int32_t numColumns) {
+ if (row < 0) {
+ row += numRows;
+ column += 4 - ((numRows + 4) & 0x07);
+ }
+ if (column < 0) {
+ column += numColumns;
+ row += 4 - ((numColumns + 4) & 0x07);
+ }
+ m_readMappingMatrix->Set(column, row);
+ return m_mappingBitMatrix->Get(column, row);
}
-int32_t CBC_DataMatrixBitMatrixParser::ReadUtah(int32_t row, int32_t column, int32_t numRows, int32_t numColumns)
-{
- int32_t currentByte = 0;
- if (ReadModule(row - 2, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row - 2, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row - 1, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row - 1, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row - 1, column, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(row, column, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
+int32_t CBC_DataMatrixBitMatrixParser::ReadUtah(int32_t row,
+ int32_t column,
+ int32_t numRows,
+ int32_t numColumns) {
+ int32_t currentByte = 0;
+ if (ReadModule(row - 2, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row - 2, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row - 1, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row - 1, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row - 1, column, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(row, column, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
}
-int32_t CBC_DataMatrixBitMatrixParser::ReadCorner1(int32_t numRows, int32_t numColumns)
-{
- int32_t currentByte = 0;
- if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 1, 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 1, 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(2, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(3, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
+int32_t CBC_DataMatrixBitMatrixParser::ReadCorner1(int32_t numRows,
+ int32_t numColumns) {
+ int32_t currentByte = 0;
+ if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 1, 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 1, 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(2, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(3, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
}
-int32_t CBC_DataMatrixBitMatrixParser::ReadCorner2(int32_t numRows, int32_t numColumns)
-{
- int32_t currentByte = 0;
- if (ReadModule(numRows - 3, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 2, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 4, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
+int32_t CBC_DataMatrixBitMatrixParser::ReadCorner2(int32_t numRows,
+ int32_t numColumns) {
+ int32_t currentByte = 0;
+ if (ReadModule(numRows - 3, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 2, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 4, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
}
-int32_t CBC_DataMatrixBitMatrixParser::ReadCorner3(int32_t numRows, int32_t numColumns)
-{
- int32_t currentByte = 0;
- if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
+int32_t CBC_DataMatrixBitMatrixParser::ReadCorner3(int32_t numRows,
+ int32_t numColumns) {
+ int32_t currentByte = 0;
+ if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
}
-int32_t CBC_DataMatrixBitMatrixParser::ReadCorner4(int32_t numRows, int32_t numColumns)
-{
- int32_t currentByte = 0;
- if (ReadModule(numRows - 3, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 2, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(2, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (ReadModule(3, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
+int32_t CBC_DataMatrixBitMatrixParser::ReadCorner4(int32_t numRows,
+ int32_t numColumns) {
+ int32_t currentByte = 0;
+ if (ReadModule(numRows - 3, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 2, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(2, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (ReadModule(3, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
}
-CBC_CommonBitMatrix *CBC_DataMatrixBitMatrixParser::ExtractDataRegion(CBC_CommonBitMatrix *bitMatrix , int32_t &e)
-{
- int32_t symbolSizeRows = m_version->GetSymbolSizeRows();
- int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns();
- if (bitMatrix->GetHeight() != symbolSizeRows) {
- e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
- return NULL;
- }
- int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows();
- int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns();
- int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
- int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
- int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
- int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
- CBC_CommonBitMatrix *bitMatrixWithoutAlignment = FX_NEW CBC_CommonBitMatrix();
- bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow);
- int32_t dataRegionRow;
- for (dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
- int32_t dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
- int32_t dataRegionColumn;
- for (dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) {
- int32_t dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
- int32_t i;
- for (i = 0; i < dataRegionSizeRows; ++i) {
- int32_t readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
- int32_t writeRowOffset = dataRegionRowOffset + i;
- int32_t j;
- for (j = 0; j < dataRegionSizeColumns; ++j) {
- int32_t readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
- if (bitMatrix->Get(readColumnOffset, readRowOffset)) {
- int32_t writeColumnOffset = dataRegionColumnOffset + j;
- bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset);
- }
- }
- }
+CBC_CommonBitMatrix* CBC_DataMatrixBitMatrixParser::ExtractDataRegion(
+ CBC_CommonBitMatrix* bitMatrix,
+ int32_t& e) {
+ int32_t symbolSizeRows = m_version->GetSymbolSizeRows();
+ int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns();
+ if (bitMatrix->GetHeight() != symbolSizeRows) {
+ e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
+ return NULL;
+ }
+ int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows();
+ int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns();
+ int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
+ int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
+ int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
+ int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
+ CBC_CommonBitMatrix* bitMatrixWithoutAlignment = FX_NEW CBC_CommonBitMatrix();
+ bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow);
+ int32_t dataRegionRow;
+ for (dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
+ int32_t dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
+ int32_t dataRegionColumn;
+ for (dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn;
+ ++dataRegionColumn) {
+ int32_t dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
+ int32_t i;
+ for (i = 0; i < dataRegionSizeRows; ++i) {
+ int32_t readRowOffset =
+ dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
+ int32_t writeRowOffset = dataRegionRowOffset + i;
+ int32_t j;
+ for (j = 0; j < dataRegionSizeColumns; ++j) {
+ int32_t readColumnOffset =
+ dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
+ if (bitMatrix->Get(readColumnOffset, readRowOffset)) {
+ int32_t writeColumnOffset = dataRegionColumnOffset + j;
+ bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset);
+ }
}
+ }
}
- return bitMatrixWithoutAlignment;
+ }
+ return bitMatrixWithoutAlignment;
}