add dataspan

This commit is contained in:
Bechir Braham
2024-03-20 16:27:22 +01:00
parent c1ddb84bc0
commit e04d1e28f9
8 changed files with 195 additions and 4 deletions

View File

@ -1,6 +1,6 @@
#include "aare/Frame.hpp"
#include <iostream>
#include <cassert>
Frame::Frame(std::byte* bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth):
m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
m_data = new std::byte[rows*cols*bitdepth/8];
@ -22,6 +22,19 @@ std::byte* Frame::get(int row, int col) {
return m_data+(row*m_cols + col)*(m_bitdepth/8);
}
template <typename T>
void Frame::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);
}
template void Frame::set(int row, int col, uint16_t data);
// std::vector<std::vector<DataType>> Frame<DataType>::get_array() {
// std::vector<std::vector<DataType>> array;
// for (int i = 0; i < m_rows; i++) {