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

Side by Side Diff: xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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/pdf417/BC_PDF417Writer.h ('k') | xfa/fxbarcode/qrcode/BC_QRCodeWriter.h » ('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 2012 ZXing authors 8 * Copyright 2012 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 11 matching lines...) Expand all
22 22
23 #include "xfa/fxbarcode/BC_TwoDimWriter.h" 23 #include "xfa/fxbarcode/BC_TwoDimWriter.h"
24 #include "xfa/fxbarcode/common/BC_CommonBitArray.h" 24 #include "xfa/fxbarcode/common/BC_CommonBitArray.h"
25 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" 25 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
26 #include "xfa/fxbarcode/pdf417/BC_PDF417.h" 26 #include "xfa/fxbarcode/pdf417/BC_PDF417.h"
27 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" 27 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h"
28 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" 28 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h"
29 #include "xfa/fxbarcode/pdf417/BC_PDF417Writer.h" 29 #include "xfa/fxbarcode/pdf417/BC_PDF417Writer.h"
30 30
31 CBC_PDF417Writer::CBC_PDF417Writer() { 31 CBC_PDF417Writer::CBC_PDF417Writer() {
32 m_bFixedSize = FALSE; 32 m_bFixedSize = false;
33 } 33 }
34 CBC_PDF417Writer::~CBC_PDF417Writer() { 34 CBC_PDF417Writer::~CBC_PDF417Writer() {
35 m_bTruncated = TRUE; 35 m_bTruncated = true;
36 } 36 }
37 FX_BOOL CBC_PDF417Writer::SetErrorCorrectionLevel(int32_t level) { 37 bool CBC_PDF417Writer::SetErrorCorrectionLevel(int32_t level) {
38 if (level < 0 || level > 8) { 38 if (level < 0 || level > 8) {
39 return FALSE; 39 return false;
40 } 40 }
41 m_iCorrectLevel = level; 41 m_iCorrectLevel = level;
42 return TRUE; 42 return true;
43 } 43 }
44 void CBC_PDF417Writer::SetTruncated(FX_BOOL truncated) { 44 void CBC_PDF417Writer::SetTruncated(bool truncated) {
45 m_bTruncated = truncated; 45 m_bTruncated = truncated;
46 } 46 }
47 uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, 47 uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents,
48 int32_t& outWidth, 48 int32_t& outWidth,
49 int32_t& outHeight, 49 int32_t& outHeight,
50 int32_t& e) { 50 int32_t& e) {
51 CBC_PDF417 encoder; 51 CBC_PDF417 encoder;
52 int32_t col = (m_Width / m_ModuleWidth - 69) / 17; 52 int32_t col = (m_Width / m_ModuleWidth - 69) / 17;
53 int32_t row = m_Height / (m_ModuleWidth * 20); 53 int32_t row = m_Height / (m_ModuleWidth * 20);
54 if (row >= 3 && row <= 90 && col >= 1 && col <= 30) { 54 if (row >= 3 && row <= 90 && col >= 1 && col <= 30) {
55 encoder.setDimensions(col, col, row, row); 55 encoder.setDimensions(col, col, row, row);
56 } else if (col >= 1 && col <= 30) { 56 } else if (col >= 1 && col <= 30) {
57 encoder.setDimensions(col, col, 90, 3); 57 encoder.setDimensions(col, col, 90, 3);
58 } else if (row >= 3 && row <= 90) { 58 } else if (row >= 3 && row <= 90) {
59 encoder.setDimensions(30, 1, row, row); 59 encoder.setDimensions(30, 1, row, row);
60 } 60 }
61 encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e); 61 encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e);
62 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 62 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
63 int32_t lineThickness = 2; 63 int32_t lineThickness = 2;
64 int32_t aspectRatio = 4; 64 int32_t aspectRatio = 4;
65 CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); 65 CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix();
66 CFX_ByteArray originalScale; 66 CFX_ByteArray originalScale;
67 originalScale.Copy(barcodeMatrix->getScaledMatrix( 67 originalScale.Copy(barcodeMatrix->getScaledMatrix(
68 lineThickness, aspectRatio * lineThickness)); 68 lineThickness, aspectRatio * lineThickness));
69 int32_t width = outWidth; 69 int32_t width = outWidth;
70 int32_t height = outHeight; 70 int32_t height = outHeight;
71 outWidth = barcodeMatrix->getWidth(); 71 outWidth = barcodeMatrix->getWidth();
72 outHeight = barcodeMatrix->getHeight(); 72 outHeight = barcodeMatrix->getHeight();
73 FX_BOOL rotated = FALSE; 73 bool rotated = false;
74 if ((height > width) ^ (outWidth < outHeight)) { 74 if ((height > width) ^ (outWidth < outHeight)) {
75 rotateArray(originalScale, outHeight, outWidth); 75 rotateArray(originalScale, outHeight, outWidth);
76 rotated = TRUE; 76 rotated = true;
77 int32_t temp = outHeight; 77 int32_t temp = outHeight;
78 outHeight = outWidth; 78 outHeight = outWidth;
79 outWidth = temp; 79 outWidth = temp;
80 } 80 }
81 int32_t scaleX = width / outWidth; 81 int32_t scaleX = width / outWidth;
82 int32_t scaleY = height / outHeight; 82 int32_t scaleY = height / outHeight;
83 int32_t scale; 83 int32_t scale;
84 if (scaleX < scaleY) { 84 if (scaleX < scaleY) {
85 scale = scaleX; 85 scale = scaleX;
86 } else { 86 } else {
(...skipping 19 matching lines...) Expand all
106 int32_t width) { 106 int32_t width) {
107 CFX_ByteArray temp; 107 CFX_ByteArray temp;
108 temp.Copy(bitarray); 108 temp.Copy(bitarray);
109 for (int32_t ii = 0; ii < height; ii++) { 109 for (int32_t ii = 0; ii < height; ii++) {
110 int32_t inverseii = height - ii - 1; 110 int32_t inverseii = height - ii - 1;
111 for (int32_t jj = 0; jj < width; jj++) { 111 for (int32_t jj = 0; jj < width; jj++) {
112 bitarray[jj * height + inverseii] = temp[ii * width + jj]; 112 bitarray[jj * height + inverseii] = temp[ii * width + jj];
113 } 113 }
114 } 114 }
115 } 115 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/pdf417/BC_PDF417Writer.h ('k') | xfa/fxbarcode/qrcode/BC_QRCodeWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698