aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/src/nopencv.hpp
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-06-02 11:31:38 +0200
committerjaseg <git@jaseg.de>2021-06-02 11:31:38 +0200
commit536a34cd59258d3a75d4caa8431fc688b1e788f6 (patch)
tree836b9dec3a315febb76af9a7c6470a4b364bfeed /svg-flatten/src/nopencv.hpp
parentd18b8a1d80185a800e18db935f04dc63cd9e1637 (diff)
downloadgerbolyze-536a34cd59258d3a75d4caa8431fc688b1e788f6.tar.gz
gerbolyze-536a34cd59258d3a75d4caa8431fc688b1e788f6.tar.bz2
gerbolyze-536a34cd59258d3a75d4caa8431fc688b1e788f6.zip
Prettify test cases
Diffstat (limited to 'svg-flatten/src/nopencv.hpp')
-rw-r--r--svg-flatten/src/nopencv.hpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/svg-flatten/src/nopencv.hpp b/svg-flatten/src/nopencv.hpp
index 9be2434..51a068a 100644
--- a/svg-flatten/src/nopencv.hpp
+++ b/svg-flatten/src/nopencv.hpp
@@ -41,23 +41,20 @@ namespace gerbolyze {
class Image32 {
public:
- Image32(int size_x, int size_y, const int32_t *data=nullptr) {
- assert(size_x > 0 && size_x < 100000);
- assert(size_y > 0 && size_y < 100000);
- m_data = new int32_t[size_x * size_y] { 0 };
- m_rows = size_y;
- m_cols = size_x;
- if (data != nullptr) {
- memcpy(m_data, data, sizeof(int32_t) * size_x * size_y);
- }
- }
-
+ Image32() {}
+ Image32(int size_x, int size_y, const int32_t *data=nullptr);
Image32(const Image32 &other) : Image32(other.cols(), other.rows(), other.ptr()) {}
~Image32() {
- delete m_data;
+ if (m_data) {
+ delete m_data;
+ }
}
+ bool load(const char *filename);
+ bool load_memory(uint8_t *buf, size_t len);
+ void binarize();
+
int32_t &at(int x, int y) {
assert(x >= 0 && y >= 0 && x < m_cols && y < m_rows);
assert(m_data != nullptr);
@@ -93,9 +90,12 @@ namespace gerbolyze {
int rows() const { return m_rows; }
int cols() const { return m_cols; }
+ int size() const { return m_cols*m_rows; }
const int32_t *ptr() const { return m_data; }
private:
+ bool stb_to_internal(uint8_t *data);
+
int32_t *m_data = nullptr;
int m_rows=0, m_cols=0;
};