mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-14 00:07:13 +02:00
saving work
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
IFrame::IFrame(std::byte* bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
|
||||
FrameImpl::FrameImpl(std::byte* bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
|
||||
{
|
||||
this->rows = rows;
|
||||
this->cols = cols;
|
||||
@ -10,7 +10,7 @@ IFrame::IFrame(std::byte* bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
|
||||
std::memcpy(data, bytes, bitdepth/8 * rows * cols);
|
||||
}
|
||||
|
||||
std::byte* IFrame::get(int row, int col) {
|
||||
std::byte* FrameImpl::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;
|
||||
|
@ -13,24 +13,29 @@
|
||||
* model class
|
||||
* should be able to work with streams coming from files or network
|
||||
*/
|
||||
class IFrame {
|
||||
|
||||
class FrameImpl {
|
||||
protected:
|
||||
std::byte* data{nullptr};
|
||||
ssize_t rows{};
|
||||
ssize_t cols{};
|
||||
ssize_t bitdepth{};
|
||||
public:
|
||||
IFrame(std::byte* fp, ssize_t rows, ssize_t cols, ssize_t bitdepth);
|
||||
FrameImpl(std::byte* fp, ssize_t rows, ssize_t cols, ssize_t bitdepth);
|
||||
std::byte* get(int row, int col);
|
||||
~IFrame(){
|
||||
~FrameImpl(){
|
||||
delete[] data;
|
||||
}
|
||||
};
|
||||
|
||||
template <class DataType> class Frame: public IFrame {
|
||||
template <class DataType> class Frame: public FrameImpl {
|
||||
public:
|
||||
Frame(std::byte* fp, ssize_t rows, ssize_t cols):IFrame(fp, rows, cols, sizeof(DataType)){}
|
||||
Frame(std::byte* fp, ssize_t rows, ssize_t cols):FrameImpl(fp, rows, cols, sizeof(DataType)){}
|
||||
DataType get(int row, int col){
|
||||
return *((DataType*) IFrame::get(row, col));
|
||||
return *((DataType*) FrameImpl::get(row, col));
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
typedef Frame<uint16_t> Frame16;
|
||||
typedef Frame<uint8_t> Frame8;
|
||||
typedef Frame<uint32_t> Frame32;
|
Reference in New Issue
Block a user