mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-14 08:17:13 +02:00
add dataspan
This commit is contained in:
@ -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++) {
|
||||
|
Reference in New Issue
Block a user