// Copyright (2019-2024) Paul Scherrer Institute #ifndef JUNGFRAUJOCH_PREVIEWIMAGE_H #define JUNGFRAUJOCH_PREVIEWIMAGE_H #include #include #include "../common/SpotToSave.h" #include "../common/DiffractionExperiment.h" #include "PreviewCounter.h" struct PreviewJPEGSettings { int64_t saturation_value = 10; int64_t jpeg_quality = 70; bool show_spots = true; bool show_roi = false; bool show_indexed = false; }; struct rgb { unsigned char r; unsigned char g; unsigned char b; }; class PreviewImage { mutable std::mutex m; const ROIMap roi_map; std::vector uncompressed_image; std::vector spots; size_t xpixel; size_t ypixel; size_t pixel_depth_bytes; bool pixel_is_signed; float beam_x; float beam_y; void AddBeamCenter(std::vector &rgb_image) const; void AddSpots(std::vector &rgb_image) const; void AddROI(std::vector &rgb_image) const; PreviewCounter counter; void color_pixel(std::vector& ret, int64_t xpixel, int64_t ypixel, const rgb &color) const; void spot(std::vector& ret, int64_t xpixel, int64_t ypixel, bool indexed) const; void roi(std::vector& ret, int64_t xpixel, int64_t ypixel, int64_t roi_number) const; void beam_center_mark(std::vector& ret, int64_t xpixel, int64_t ypixel) const; public: explicit PreviewImage(const DiffractionExperiment& experiment); void UpdateImage(const void *uncompressed_image, const std::vector &spots); [[nodiscard]] std::string GenerateJPEG(const PreviewJPEGSettings& settings) const; [[nodiscard]] std::string GenerateTIFF() const; [[nodiscard]] std::string GenerateTIFFDioptas() const; }; #endif //JUNGFRAUJOCH_PREVIEWIMAGE_H