read jungfrau simple file. leak errors

This commit is contained in:
Bechir Braham
2024-02-22 15:14:16 +01:00
parent a6ff0fc794
commit 315bf6eb5d
19 changed files with 359 additions and 100 deletions

View File

@ -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")

View File

@ -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>;

View File

@ -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);
};