summaryrefslogtreecommitdiff
path: root/fxbarcode/common/BC_CommonByteMatrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxbarcode/common/BC_CommonByteMatrix.cpp')
-rw-r--r--fxbarcode/common/BC_CommonByteMatrix.cpp45
1 files changed, 16 insertions, 29 deletions
diff --git a/fxbarcode/common/BC_CommonByteMatrix.cpp b/fxbarcode/common/BC_CommonByteMatrix.cpp
index 2ab1e9ac50..db0a4a9647 100644
--- a/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -19,46 +19,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "fxbarcode/common/BC_CommonByteMatrix.h"
+#include <algorithm>
+#include <iterator>
#include "core/fxcrt/fx_memory.h"
-#include "fxbarcode/common/BC_CommonByteMatrix.h"
+#include "third_party/base/stl_util.h"
-CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) {
- m_height = height;
- m_width = width;
- m_bytes = nullptr;
-}
-void CBC_CommonByteMatrix::Init() {
- m_bytes = FX_Alloc2D(uint8_t, m_height, m_width);
- memset(m_bytes, 0xff, m_height * m_width);
-}
-CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
- FX_Free(m_bytes);
-}
-int32_t CBC_CommonByteMatrix::GetHeight() {
- return m_height;
-}
-int32_t CBC_CommonByteMatrix::GetWidth() {
- return m_width;
+CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height)
+ : m_width(width), m_height(height) {
+ m_bytes = pdfium::Vector2D<uint8_t>(m_height, m_width);
+ clear(0xff);
}
-uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) {
+
+CBC_CommonByteMatrix::~CBC_CommonByteMatrix() = default;
+
+uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) const {
return m_bytes[y * m_width + x];
}
+
void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) {
m_bytes[y * m_width + x] = (uint8_t)value;
}
+
void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) {
m_bytes[y * m_width + x] = value;
}
+
void CBC_CommonByteMatrix::clear(uint8_t value) {
- int32_t y;
- for (y = 0; y < m_height; y++) {
- int32_t x;
- for (x = 0; x < m_width; x++) {
- m_bytes[y * m_width + x] = value;
- }
- }
-}
-uint8_t* CBC_CommonByteMatrix::GetArray() {
- return m_bytes;
+ std::fill(std::begin(m_bytes), std::end(m_bytes), value);
}