OLD | NEW |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ArrayTemplate<uint8_t> 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 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; |
(...skipping 17 matching lines...) Expand all Loading... |
94 rotateArray(originalScale, outHeight, outWidth); | 94 rotateArray(originalScale, outHeight, outWidth); |
95 int32_t temp = outHeight; | 95 int32_t temp = outHeight; |
96 outHeight = outWidth; | 96 outHeight = outWidth; |
97 outWidth = temp; | 97 outWidth = temp; |
98 } | 98 } |
99 } | 99 } |
100 uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth); | 100 uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth); |
101 FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth); | 101 FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth); |
102 return result; | 102 return result; |
103 } | 103 } |
104 void CBC_PDF417Writer::rotateArray(CFX_ByteArray& bitarray, | 104 void CBC_PDF417Writer::rotateArray(CFX_ArrayTemplate<uint8_t>& bitarray, |
105 int32_t height, | 105 int32_t height, |
106 int32_t width) { | 106 int32_t width) { |
107 CFX_ByteArray temp; | 107 CFX_ArrayTemplate<uint8_t> 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 } |
OLD | NEW |