Go to the documentation of this file.
9 #ifndef OGLPLUS_UTILS_IMAGE_FILE_IO_HPP
10 #define OGLPLUS_UTILS_IMAGE_FILE_IO_HPP
18 namespace eagine::oglp {
20 inline void write_and_pad_texture_image_data_header(
22 image_data_header& header,
26 while(!is_aligned_as<image_data_header>(spos)) {
33 static_assert(size >=
span_size(
sizeof(image_data_header)));
37 header.pixels.reset(hdraddr + size, pixel_data_size);
39 output.write(
static_cast<const char*
>(hdraddr),
sizeof(header));
40 spos +=
sizeof(header);
41 done +=
sizeof(header);
50 inline void write_and_pad_texture_image_data_header(
52 image_data_header& header,
56 if(output.tellp() >= 0) {
60 write_and_pad_texture_image_data_header(
61 output, header, pixel_data_size, spos);
64 inline void write_texture_image_data(
66 image_data_header& header,
68 write_and_pad_texture_image_data_header(
69 output, header,
span_size(pixels.size()));
71 write_to_stream(output, pixels);
76 #endif // OGLPLUS_UTILS_IMAGE_FILE_IO_HPP
Class for handling memory addresses as integer values.
Definition: address.hpp:23
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
static constexpr auto span_size(T v) noexcept
Converts argument to span size type.
Definition: types.hpp:59
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
static constexpr auto is_aligned_as(const_address addr, type_identity< T > tid={}) noexcept
Indicates if a memory address aligned as the specified type T.
Definition: address.hpp:244