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 2007 ZXing authors | 8 * Copyright 2007 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 Loading... |
42 m_width = width; | 42 m_width = width; |
43 m_height = height; | 43 m_height = height; |
44 int32_t rowSize = (width + 31) >> 5; | 44 int32_t rowSize = (width + 31) >> 5; |
45 m_rowSize = rowSize; | 45 m_rowSize = rowSize; |
46 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); | 46 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); |
47 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); | 47 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); |
48 } | 48 } |
49 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { | 49 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { |
50 FX_Free(m_bits); | 50 FX_Free(m_bits); |
51 } | 51 } |
52 FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { | 52 bool CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { |
53 int32_t offset = y * m_rowSize + (x >> 5); | 53 int32_t offset = y * m_rowSize + (x >> 5); |
54 if (offset >= m_rowSize * m_height || offset < 0) { | 54 if (offset >= m_rowSize * m_height || offset < 0) { |
55 return false; | 55 return false; |
56 } | 56 } |
57 return ((((uint32_t)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; | 57 return ((((uint32_t)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; |
58 } | 58 } |
59 int32_t* CBC_CommonBitMatrix::GetBits() { | 59 int32_t* CBC_CommonBitMatrix::GetBits() { |
60 return m_bits; | 60 return m_bits; |
61 } | 61 } |
62 void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) { | 62 void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int32_t CBC_CommonBitMatrix::GetRowSize() { | 137 int32_t CBC_CommonBitMatrix::GetRowSize() { |
138 return m_rowSize; | 138 return m_rowSize; |
139 } | 139 } |
140 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { | 140 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { |
141 if (m_width != m_height) { | 141 if (m_width != m_height) { |
142 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; | 142 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; |
143 return 0; | 143 return 0; |
144 } | 144 } |
145 return m_width; | 145 return m_width; |
146 } | 146 } |
OLD | NEW |