mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-14 08:17:13 +02:00
read jungfrau simple file. leak errors
This commit is contained in:
@ -1 +1,3 @@
|
||||
target_include_directories(aare PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_include_directories(aare PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_sources(aare PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Frame.cpp")
|
@ -1,3 +1,26 @@
|
||||
#include "Frame.hpp"
|
||||
#include <iostream>
|
||||
|
||||
ssize_t Frame::cols() const { return ssize_t(); }
|
||||
|
||||
template <class DataType>
|
||||
Frame<DataType>::Frame(std::byte* bytes, ssize_t rows, ssize_t cols)
|
||||
{
|
||||
this->rows = rows;
|
||||
this->cols = cols;
|
||||
data = new DataType[rows * cols];
|
||||
std::memcpy(data, bytes, sizeof(DataType) * rows * cols);
|
||||
}
|
||||
|
||||
template <class 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;
|
||||
}
|
||||
return data[row * cols + col];
|
||||
|
||||
|
||||
}
|
||||
|
||||
template class Frame<uint16_t>;
|
||||
template class Frame<uint32_t>;
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <sys/types.h>
|
||||
#include <cstdint>
|
||||
@ -5,20 +6,19 @@
|
||||
#include <vector>
|
||||
#include "defs.hpp"
|
||||
|
||||
class Frame{
|
||||
|
||||
ssize_t nrows{};
|
||||
ssize_t ncols{};
|
||||
uint8_t bitdepth_{};
|
||||
std::unique_ptr<std::byte[]> data_{nullptr};
|
||||
public:
|
||||
ssize_t rows() const;
|
||||
ssize_t cols() const;
|
||||
image_shape shape() const;
|
||||
uint8_t bits_per_pixel() const;
|
||||
uint8_t bytes_per_pixel() const;
|
||||
size_t total_bytes() const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Frame class to represent a single frame of data
|
||||
* model class
|
||||
* should be able to work with streams coming from files or network
|
||||
*/
|
||||
template <class DataType>
|
||||
class Frame {
|
||||
|
||||
DataType* data{nullptr};
|
||||
ssize_t rows{};
|
||||
ssize_t cols{};
|
||||
public:
|
||||
Frame(std::byte* fp, ssize_t rows, ssize_t cols);
|
||||
DataType get(int row, int col);
|
||||
};
|
Reference in New Issue
Block a user