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

Side by Side Diff: xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "BC_Base256Encoder.h" 42 #include "BC_Base256Encoder.h"
43 #include "BC_ASCIIEncoder.h" 43 #include "BC_ASCIIEncoder.h"
44 #include "BC_HighLevelEncoder.h" 44 #include "BC_HighLevelEncoder.h"
45 #include "BC_DataMatrixWriter.h" 45 #include "BC_DataMatrixWriter.h"
46 CBC_DataMatrixWriter::CBC_DataMatrixWriter() 46 CBC_DataMatrixWriter::CBC_DataMatrixWriter()
47 { 47 {
48 } 48 }
49 CBC_DataMatrixWriter::~CBC_DataMatrixWriter() 49 CBC_DataMatrixWriter::~CBC_DataMatrixWriter()
50 { 50 {
51 } 51 }
52 FX_BOOL CBC_DataMatrixWriter::SetErrorCorrectionLevel (FX_INT32 level) 52 FX_BOOL CBC_DataMatrixWriter::SetErrorCorrectionLevel (int32_t level)
53 { 53 {
54 m_iCorrectLevel = level; 54 m_iCorrectLevel = level;
55 return TRUE; 55 return TRUE;
56 } 56 }
57 FX_BYTE* CBC_DataMatrixWriter::Encode(const CFX_WideString &contents, FX_INT32 & outWidth, FX_INT32 &outHeight, FX_INT32 &e) 57 uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString &contents, int32_t &o utWidth, int32_t &outHeight, int32_t &e)
58 { 58 {
59 if (outWidth < 0 || outHeight < 0) { 59 if (outWidth < 0 || outHeight < 0) {
60 e = BCExceptionHeightAndWidthMustBeAtLeast1; 60 e = BCExceptionHeightAndWidthMustBeAtLeast1;
61 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 61 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
62 } 62 }
63 CBC_SymbolShapeHint::SymbolShapeHint shape = CBC_SymbolShapeHint::FORCE_SQUA RE; 63 CBC_SymbolShapeHint::SymbolShapeHint shape = CBC_SymbolShapeHint::FORCE_SQUA RE;
64 CBC_Dimension* minSize = NULL; 64 CBC_Dimension* minSize = NULL;
65 CBC_Dimension* maxSize = NULL; 65 CBC_Dimension* maxSize = NULL;
66 CFX_WideString ecLevel; 66 CFX_WideString ecLevel;
67 CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel(contents, ecL evel, shape, minSize, maxSize, e); 67 CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel(contents, ecL evel, shape, minSize, maxSize, e);
68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
69 CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup(encoded.GetLength(), sha pe, minSize, maxSize, TRUE, e); 69 CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup(encoded.GetLength(), sha pe, minSize, maxSize, TRUE, e);
70 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 70 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
71 CFX_WideString codewords = CBC_ErrorCorrection::encodeECC200(encoded, symbol Info, e); 71 CFX_WideString codewords = CBC_ErrorCorrection::encodeECC200(encoded, symbol Info, e);
72 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 72 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
73 CBC_DefaultPlacement* placement = FX_NEW CBC_DefaultPlacement(codewords, sym bolInfo->getSymbolDataWidth(e), symbolInfo->getSymbolDataHeight(e)); 73 CBC_DefaultPlacement* placement = FX_NEW CBC_DefaultPlacement(codewords, sym bolInfo->getSymbolDataWidth(e), symbolInfo->getSymbolDataHeight(e));
74 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 74 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
75 placement->place(); 75 placement->place();
76 CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e); 76 CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e);
77 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 77 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
78 outWidth = bytematrix->GetWidth(); 78 outWidth = bytematrix->GetWidth();
79 outHeight = bytematrix->GetHeight(); 79 outHeight = bytematrix->GetHeight();
80 FX_BYTE* result = FX_Alloc(FX_BYTE, outWidth * outHeight); 80 uint8_t* result = FX_Alloc(uint8_t, outWidth * outHeight);
81 FXSYS_memcpy32(result, bytematrix->GetArray(), outWidth * outHeight); 81 FXSYS_memcpy32(result, bytematrix->GetArray(), outWidth * outHeight);
82 delete bytematrix; 82 delete bytematrix;
83 delete placement; 83 delete placement;
84 return result; 84 return result;
85 } 85 }
86 FX_BYTE *CBC_DataMatrixWriter::Encode(const CFX_ByteString &contents, BCFORMAT f ormat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 &e) 86 uint8_t *CBC_DataMatrixWriter::Encode(const CFX_ByteString &contents, BCFORMAT f ormat, int32_t &outWidth, int32_t &outHeight, int32_t &e)
87 { 87 {
88 return NULL; 88 return NULL;
89 } 89 }
90 FX_BYTE *CBC_DataMatrixWriter::Encode(const CFX_ByteString &contents, BCFORMAT f ormat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 hints, FX_INT32 &e) 90 uint8_t *CBC_DataMatrixWriter::Encode(const CFX_ByteString &contents, BCFORMAT f ormat, int32_t &outWidth, int32_t &outHeight, int32_t hints, int32_t &e)
91 { 91 {
92 return NULL; 92 return NULL;
93 } 93 }
94 CBC_CommonByteMatrix* CBC_DataMatrixWriter::encodeLowLevel(CBC_DefaultPlacement* placement, CBC_SymbolInfo* symbolInfo, FX_INT32 &e) 94 CBC_CommonByteMatrix* CBC_DataMatrixWriter::encodeLowLevel(CBC_DefaultPlacement* placement, CBC_SymbolInfo* symbolInfo, int32_t &e)
95 { 95 {
96 FX_INT32 symbolWidth = symbolInfo->getSymbolDataWidth(e); 96 int32_t symbolWidth = symbolInfo->getSymbolDataWidth(e);
97 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 97 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
98 FX_INT32 symbolHeight = symbolInfo->getSymbolDataHeight(e); 98 int32_t symbolHeight = symbolInfo->getSymbolDataHeight(e);
99 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 99 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
100 CBC_CommonByteMatrix* matrix = FX_NEW CBC_CommonByteMatrix(symbolInfo->getSy mbolWidth(e), symbolInfo->getSymbolHeight(e)); 100 CBC_CommonByteMatrix* matrix = FX_NEW CBC_CommonByteMatrix(symbolInfo->getSy mbolWidth(e), symbolInfo->getSymbolHeight(e));
101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
102 matrix->Init(); 102 matrix->Init();
103 FX_INT32 matrixY = 0; 103 int32_t matrixY = 0;
104 for (FX_INT32 y = 0; y < symbolHeight; y++) { 104 for (int32_t y = 0; y < symbolHeight; y++) {
105 FX_INT32 matrixX; 105 int32_t matrixX;
106 if ((y % symbolInfo->m_matrixHeight) == 0) { 106 if ((y % symbolInfo->m_matrixHeight) == 0) {
107 matrixX = 0; 107 matrixX = 0;
108 for (FX_INT32 x = 0; x < symbolInfo->getSymbolWidth(e); x++) { 108 for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) {
109 matrix->Set(matrixX, matrixY, (x % 2) == 0); 109 matrix->Set(matrixX, matrixY, (x % 2) == 0);
110 matrixX++; 110 matrixX++;
111 } 111 }
112 matrixY++; 112 matrixY++;
113 } 113 }
114 matrixX = 0; 114 matrixX = 0;
115 for (FX_INT32 x = 0; x < symbolWidth; x++) { 115 for (int32_t x = 0; x < symbolWidth; x++) {
116 if ((x % symbolInfo->m_matrixWidth) == 0) { 116 if ((x % symbolInfo->m_matrixWidth) == 0) {
117 matrix->Set(matrixX, matrixY, TRUE); 117 matrix->Set(matrixX, matrixY, TRUE);
118 matrixX++; 118 matrixX++;
119 } 119 }
120 matrix->Set(matrixX, matrixY, placement->getBit(x, y)); 120 matrix->Set(matrixX, matrixY, placement->getBit(x, y));
121 matrixX++; 121 matrixX++;
122 if ((x % symbolInfo->m_matrixWidth) == symbolInfo->m_matrixWidth - 1 ) { 122 if ((x % symbolInfo->m_matrixWidth) == symbolInfo->m_matrixWidth - 1 ) {
123 matrix->Set(matrixX, matrixY, (y % 2) == 0); 123 matrix->Set(matrixX, matrixY, (y % 2) == 0);
124 matrixX++; 124 matrixX++;
125 } 125 }
126 } 126 }
127 matrixY++; 127 matrixY++;
128 if ((y % symbolInfo->m_matrixHeight) == symbolInfo->m_matrixHeight - 1) { 128 if ((y % symbolInfo->m_matrixHeight) == symbolInfo->m_matrixHeight - 1) {
129 matrixX = 0; 129 matrixX = 0;
130 for (FX_INT32 x = 0; x < symbolInfo->getSymbolWidth(e); x++) { 130 for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) {
131 matrix->Set(matrixX, matrixY, TRUE); 131 matrix->Set(matrixX, matrixY, TRUE);
132 matrixX++; 132 matrixX++;
133 } 133 }
134 matrixY++; 134 matrixY++;
135 } 135 }
136 } 136 }
137 return matrix; 137 return matrix;
138 } 138 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h ('k') | xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698