Files
kouryu/serfile.h
T
2025-10-12 13:35:22 +02:00

69 lines
1.5 KiB
C++

#ifndef SERFILE_H
#define SERFILE_H
#include <QFile>
enum SERPixelFormat : uint32_t
{
MONO = 0,
BAYER_RGGB = 8,
BAYER_GRBG = 9,
BAYER_GBRG = 10,
BAYER_BGGR = 11,
BAYER_CYYM = 16,
BAYER_YCMY = 17,
BAYER_YMCY = 18,
BAYER_MYYC = 19,
RGB = 100,
BGR = 101
};
struct __attribute__ ((packed)) SERHeader
{
char fileid[14] = {'L','U','C','A','M','-','R','E','C','O','R','D','E','R'};
uint32_t lulid = 0;
SERPixelFormat colorid = MONO;
uint32_t littleendian = 0;
uint32_t imagewidth = 0;
uint32_t imageheight = 0;
uint32_t pixeldepth = 0;
uint32_t framecount = 0;
char observer[40] = {0};
char instrument[40] = {0};
char telescope[40] = {0};
int64_t datetime = 0;
int64_t datetime_utc = 0;
};
class SERFileWriter
{
public:
SERFileWriter();
~SERFileWriter();
bool open(const QString &path, int w, int h, SERPixelFormat format, int bitdepth);
void close();
bool writeFrame(const QImage &img);
private:
int64_t getTimestamp();
QFile _fw;
SERHeader _header;
std::vector<int64_t> _timestamps;
};
class SERFileReader
{
public:
bool open(const QString &path);
uint32_t width() const;
uint32_t height() const;
uint32_t frameCount() const;
uint64_t frameSize() const;
void getFrame(int32_t index, std::vector<uint8_t> &data);
void getFrame(int32_t index, char *data);
private:
QFile _fr;
SERHeader _header;
};
#endif // SERFILE_H