renamed _get_data() to data()

This commit is contained in:
Erik Frojdh
2024-04-03 12:14:59 +02:00
parent 3f83e37e6b
commit d80ea2269f
3 changed files with 11 additions and 10 deletions

View File

@@ -26,22 +26,23 @@ class Frame {
Frame(ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
Frame(std::byte *fp, ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
std::byte *get(int row, int col);
// template <typename T> void set(int row, int col, T data);
//TODO! can we, or even want to remove the template?
template <typename T>
void set(int row, int col, T data) {
assert(sizeof(T) == m_bitdepth/8);
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
std::cerr << "Invalid row or column index" << std::endl;
return;
}
std::memcpy(m_data+(row*m_cols + col)*(m_bitdepth/8), &data, m_bitdepth/8);
}
throw std::out_of_range("Invalid row or column index");
}
std::memcpy(m_data+(row*m_cols + col)*(m_bitdepth/8), &data, m_bitdepth/8);
}
ssize_t rows() const { return m_rows; }
ssize_t cols() const { return m_cols; }
ssize_t bitdepth() const { return m_bitdepth; }
ssize_t size() const { return m_rows * m_cols * m_bitdepth / 8; }
std::byte *_get_data() { return m_data; }
std::byte *data() { return m_data; }
Frame &operator=(Frame &other) {
m_rows = other.rows();