Files
Jungfraujoch/preview/PreviewImage.h

63 lines
2.0 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"
#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;
std::optional<float> resolution_ring;
};
struct rgb {
unsigned char r;
unsigned char g;
unsigned char b;
};
class PreviewImage {
mutable std::mutex m;
DiffractionExperiment experiment;
bool initialized;
const ROIMap roi_map;
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 AddResolutionRing(std::vector<uint8_t> &rgb_image, float d) const;
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;
PreviewCounter counter;
void color_pixel(std::vector<unsigned char>& ret, int64_t xpixel, int64_t ypixel, const rgb &color) const;
void spot(std::vector<unsigned char>& ret, int64_t xpixel, int64_t ypixel, bool indexed) const;
void roi(std::vector<unsigned char>& ret, int64_t xpixel, int64_t ypixel, int64_t roi_number) const;
void beam_center_mark(std::vector<unsigned char>& ret, int64_t xpixel, int64_t ypixel) 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;
};
#endif //JUNGFRAUJOCH_PREVIEWIMAGE_H