#ifndef SERFILE_H #define SERFILE_H #include 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 _timestamps; }; class SERFileReader { public: bool open(const QString &path); void close(); uint32_t width() const; uint32_t height() const; uint32_t frameCount() const; uint64_t frameSize() const; uint32_t pixelDepth() const; SERPixelFormat pixelFormat() const; void getFrame(int32_t index, std::vector &data); void getFrame(int32_t index, char *data); private: QFile _fr; SERHeader _header; }; #endif // SERFILE_H