Files
Jungfraujoch/export_images/PreviewImage.h

45 lines
1.4 KiB
C++

// Copyright (2019-2024) Paul Scherrer Institute
#ifndef JUNGFRAUJOCH_PREVIEWIMAGE_H
#define JUNGFRAUJOCH_PREVIEWIMAGE_H
#include <vector>
#include <mutex>
#include "../common/SpotToSave.h"
#include "../common/DiffractionExperiment.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;
};
class PreviewImage {
mutable std::mutex m;
std::vector<uint16_t> roi_mask;
std::vector<uint8_t> uncompressed_image;
std::vector<SpotToSave> 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<uint8_t> &rgb_image) const;
void AddSpots(std::vector<uint8_t> &rgb_image) const;
void AddROI(std::vector<uint8_t> &rgb_image) const;
public:
explicit PreviewImage(const DiffractionExperiment& experiment);
void UpdateImage(const void *uncompressed_image, const std::vector<SpotToSave> &spots);
[[nodiscard]] std::string GenerateJPEG(const PreviewJPEGSettings& settings) const;
[[nodiscard]] std::string GenerateTIFF() const;
[[nodiscard]] std::string GenerateTIFFDioptas() const;
[[nodiscard]] static std::string GenerateTestJPEG(const PreviewJPEGSettings& settings);
};
#endif //JUNGFRAUJOCH_PREVIEWIMAGE_H