CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
pixel_format.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <cstddef>
17#include <cstdint>
18#include <utility>
19
20namespace CaptureMoment::Core {
21
22namespace Common {
23
38enum class PixelFormat : std::uint8_t {
56
65 RGB_F32,
66};
67
74[[nodiscard]] constexpr std::uint8_t getChannelCount(PixelFormat pf) noexcept
75{
76 switch(pf) {
78 return 4;
80 return 3;
81 default:
82 std::unreachable();
83 }
84}
85
92[[nodiscard]] constexpr std::size_t getPixelSizeInBytes(PixelFormat fmt) noexcept
93{
94 return static_cast<std::size_t>(getChannelCount(fmt)) * sizeof(float);
95}
96
97} // namespace Common
98
99} // namespace CaptureMoment::Core
PixelFormat
Enumerates the supported pixel storage formats in memory.
@ RGB_F32
3-channel format: Red, Green, Blue in 32-bit float.
@ RGBA_F32
4-channel format: Red, Green, Blue, Alpha in 32-bit float.
constexpr std::uint8_t getChannelCount(PixelFormat pf) noexcept
Returns the number of channels for a given PixelFormat.
constexpr std::size_t getPixelSizeInBytes(PixelFormat fmt) noexcept
Returns the size in bytes of a single pixel for a given PixelFormat.
@ Common
General errors applicable to multiple subsystems.
Manages the lifecycle of a single IWorkingImage instance.
CaptureMoment — footer