mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-12 23:37:13 +02:00
read numpy file: works
This commit is contained in:
@ -22,6 +22,7 @@ template <class DataType> class Frame{
|
||||
ssize_t cols;
|
||||
DataType* data;
|
||||
ssize_t bitdepth = sizeof(DataType)*8;
|
||||
Frame(ssize_t rows, ssize_t cols);
|
||||
|
||||
Frame(std::byte* fp, ssize_t rows, ssize_t cols);
|
||||
DataType get(int row, int col);
|
||||
|
@ -8,13 +8,18 @@ Frame<DataType>::Frame(std::byte* bytes, ssize_t rows, ssize_t cols):
|
||||
std::memcpy(data, bytes, rows*cols*sizeof(DataType));
|
||||
}
|
||||
|
||||
template <typename DataType>
|
||||
Frame<DataType>::Frame(ssize_t rows, ssize_t cols):
|
||||
rows(rows), cols(cols) {
|
||||
data = new DataType[rows*cols];
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename DataType>
|
||||
DataType Frame<DataType>::get(int row, int col) {
|
||||
if (row < 0 || row >= rows || col < 0 || col >= cols) {
|
||||
std::cerr << "Invalid row or column index" << std::endl;
|
||||
return 0;
|
||||
throw std::runtime_error("Invalid row or column index");
|
||||
}
|
||||
return data[row*cols + col];
|
||||
}
|
||||
|
Reference in New Issue
Block a user