MeshLib Documentation
Loading...
Searching...
No Matches
MRTiffIO.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#if !defined( __EMSCRIPTEN__) && !defined( MRMESH_NO_TIFF )
4#include "MRExpected.h"
5#include "MRVector2.h"
6#include <filesystem>
7#include <string>
8
9namespace MR
10{
11
13{
14 enum class SampleType
15 {
16 Unknown,
17 Uint,
18 Int,
19 Float
20 } sampleType{ SampleType::Unknown };
21
22 enum class ValueType
23 {
24 Unknown,
25 Scalar,
26 RGB,
27 RGBA,
28 } valueType{ ValueType::Unknown };
29
30 // size of internal data in file
32
33 // size of image if not layered, otherwise size of layer
34 Vector2i imageSize;
35
36 bool operator==( const BaseTiffParameters& ) const = default;
37};
38
40{
41 // true if tif file is tiled
42 bool tiled = false;
43 Vector2i tileSize;
44 int layers = 1;
45 // tile depth (if several layers)
46 int depth = 0;
47
48 bool operator==( const TiffParameters& ) const = default;
49};
50
51// returns true if given file is tiff
52MRMESH_API bool isTIFFFile( const std::filesystem::path& path );
53
54// reads parameters of tiff file
55MRMESH_API Expected<TiffParameters> readTiffParameters( const std::filesystem::path& path );
56
58{
59 // main output data, should be allocated
60 uint8_t* bytes{ nullptr };
61 // allocated data size
62 size_t size{ 0 };
63 // optional params output
65 // optional pixel to world transform
66 AffineXf3f* p2wXf{ nullptr };
67 // input if true loads tiff file as floats array
68 bool convertToFloat{ true };
69 // min max
70 float* min{ nullptr };
71 float* max{ nullptr };
72};
73
74// load values from tiff to ouput.data
75MRMESH_API Expected<void> readRawTiff( const std::filesystem::path& path, RawTiffOutput& output );
76
77// writes bytes to tiff file
78MRMESH_API Expected<void> writeRawTiff( const uint8_t* bytes, const std::filesystem::path& path,
79 const BaseTiffParameters& params );
80
81}
82
83#endif
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRCameraOrientationPlugin.h:8
MRMESH_API Expected< void > readRawTiff(const std::filesystem::path &path, RawTiffOutput &output)
MRMESH_API bool isTIFFFile(const std::filesystem::path &path)
tl::expected< T, E > Expected
Definition MRExpected.h:58
MRMESH_API Expected< TiffParameters > readTiffParameters(const std::filesystem::path &path)
MRMESH_API Expected< void > writeRawTiff(const uint8_t *bytes, const std::filesystem::path &path, const BaseTiffParameters &params)
Definition MRTiffIO.h:13
ValueType
Definition MRTiffIO.h:23
int bytesPerSample
Definition MRTiffIO.h:31
enum MR::BaseTiffParameters::SampleType Unknown
bool operator==(const BaseTiffParameters &) const =default
SampleType
Definition MRTiffIO.h:15
Vector2i imageSize
Definition MRTiffIO.h:34
Definition MRTiffIO.h:58
uint8_t * bytes
Definition MRTiffIO.h:60
float * min
Definition MRTiffIO.h:70
TiffParameters * params
Definition MRTiffIO.h:64
AffineXf3f * p2wXf
Definition MRTiffIO.h:66
bool convertToFloat
Definition MRTiffIO.h:68
float * max
Definition MRTiffIO.h:71
size_t size
Definition MRTiffIO.h:62
Definition MRTiffIO.h:40
Vector2i tileSize
Definition MRTiffIO.h:43
bool operator==(const TiffParameters &) const =default
int layers
Definition MRTiffIO.h:44
int depth
Definition MRTiffIO.h:46
bool tiled
Definition MRTiffIO.h:42