Go to the documentation of this file.
9 #ifndef OGLPLUS_UTILS_IMAGE_FILE_HPP
10 #define OGLPLUS_UTILS_IMAGE_FILE_HPP
17 namespace eagine::oglp {
19 class texture_image_block {
21 structured_memory_block<const image_data_header> _header;
27 texture_image_block(
const image_data_header* ptr)
28 : _header(
as_bytes(view_one(ptr))) {}
30 auto is_valid() const noexcept ->
bool {
31 return _header->magic.is_valid();
34 auto dimensions() const noexcept -> image_dimensions {
35 return image_dimensions(
36 _header->width, _header->height, _header->depth, _header->channels);
39 auto format() const noexcept -> image_pixel_format {
40 return image_pixel_format(
41 pixel_format(_header->format),
42 pixel_internal_format(_header->internal_format));
45 auto format(pixel_internal_format ifmt)
const noexcept
46 -> image_pixel_format {
47 return image_pixel_format(pixel_format(_header->format), ifmt);
50 auto pixel_data() const noexcept -> image_pixel_data {
51 return image_pixel_data(
52 pixel_data_type(_header->data_type),
57 auto spec() const noexcept -> image_spec {
58 return {dimensions(),
format(), pixel_data()};
61 auto spec(pixel_internal_format ifmt)
const noexcept {
62 return image_spec(dimensions(),
format(ifmt), pixel_data());
65 inline operator image_spec() const noexcept {
70 class texture_image_file
71 : protected_member<file_contents>
72 ,
public texture_image_block {
74 texture_image_file(file_contents&& fc)
75 : protected_member<file_contents>(std::move(fc))
76 , texture_image_block(get_the_member()) {}
79 : texture_image_file(file_contents(path)) {}
81 texture_image_file(
const std::string& path)
87 #endif // OGLPLUS_UTILS_IMAGE_FILE_HPP
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static constexpr auto as_bytes(basic_span< T, P, S > spn) noexcept -> basic_block< std::is_const_v< T >>
Converts a span into a basic_block.
Definition: block.hpp:39
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
static auto format(std::string &&fmt_str) noexcept -> format_string_and_list< 0 >
Function taking a format string, returning an object for variable specification.
Definition: str_format.hpp:118