HighMap library (C++)
Loading...
Searching...
No Matches
image_writer.hpp
Go to the documentation of this file.
1/* Copyright (c) 2026 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
12#pragma once
13
14#include <memory>
15#include <string>
16#include <vector>
17
18#include "highmap/array.hpp"
20
21namespace hmap
22{
23
24// =====================================
25// Data types and configuration
26// =====================================
27
35
37{
38 glm::ivec2 image_shape = {0, 0};
39 glm::ivec2 tile_shape = {0, 0};
41 int channels = 1;
42 std::string compression = "default";
43 float remap_min = 0.f;
44 float remap_max = 1.f;
45 bool enable_remapping = false;
46};
47
48// =====================================
49// Abstract class
50// =====================================
51
53{
54public:
55 virtual ~ImageWriter() = default;
56
57 // --- Lifecycle
58
59 virtual bool open(const std::string &filepath,
60 const ImageWriterConfig &config) = 0;
61 virtual void close() = 0;
62 virtual bool is_open() const = 0;
63
64 // --- Chunk / tile writing
65
66 virtual bool write_chunk(int offset_x, int offset_y, const Array &data) = 0;
67 virtual bool write_chunk(int offset_x,
68 int offset_y,
69 const std::vector<Array> &channels);
70 virtual bool write_tile(const UvTile &region, const Array &data);
71 virtual bool write_tile(const UvTile &region,
72 const std::vector<Array> &channels);
73
74 // --- Properties
75
76 virtual const ImageWriterConfig &config() const = 0;
77 virtual const std::string &filepath() const = 0;
78
79 // --- Factory
80
81 static std::unique_ptr<ImageWriter> create(const std::string &filepath,
83};
84
85} // namespace hmap
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Definition image_writer.hpp:53
static std::unique_ptr< ImageWriter > create(const std::string &filepath, const ImageWriterConfig &config)
Definition image_writer.cpp:85
virtual bool is_open() const =0
virtual const ImageWriterConfig & config() const =0
virtual void close()=0
virtual const std::string & filepath() const =0
virtual bool write_chunk(int offset_x, int offset_y, const Array &data)=0
virtual bool open(const std::string &filepath, const ImageWriterConfig &config)=0
virtual ~ImageWriter()=default
virtual bool write_tile(const UvTile &region, const Array &data)
Definition image_writer.cpp:35
Definition opencv.hpp:20
ImageDataType
Definition image_writer.hpp:29
@ UINT16
Definition image_writer.hpp:32
@ FLOAT32
Definition image_writer.hpp:30
@ FLOAT16
Definition image_writer.hpp:31
@ UINT8
Definition image_writer.hpp:33
Definition image_writer.hpp:37
glm::ivec2 image_shape
Definition image_writer.hpp:38
ImageDataType data_type
Definition image_writer.hpp:40
glm::ivec2 tile_shape
Definition image_writer.hpp:39
int channels
Definition image_writer.hpp:41
std::string compression
Definition image_writer.hpp:42
float remap_max
Definition image_writer.hpp:44
bool enable_remapping
Definition image_writer.hpp:45
float remap_min
Definition image_writer.hpp:43
Describes an Array tile's position within the normalized [0, 1]^2 UV domain and global index grid.
Definition uv_tile.hpp:46
Normalized UV-domain tile descriptor for single-source SPMD Array algorithms and VirtualArray dispatc...