diff options
Diffstat (limited to 'kms++')
| -rw-r--r-- | kms++/inc/kms++/pixelformats.h | 2 | ||||
| -rw-r--r-- | kms++/src/pixelformats.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h index e866d84..c4dd07f 100644 --- a/kms++/inc/kms++/pixelformats.h +++ b/kms++/inc/kms++/pixelformats.h @@ -115,6 +115,8 @@ uint32_t pixel_format_to_fourcc(PixelFormat f); PixelFormat fourcc_str_to_pixel_format(const std::string& fourcc); std::string pixel_format_to_fourcc_str(PixelFormat f); +PixelFormat find_pixel_format_by_name(const std::string& name); + enum class PixelColorType { Undefined, RGB, diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index 559aa38..847c8a6 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -992,6 +992,16 @@ std::string pixel_format_to_fourcc_str(PixelFormat f) return fourcc_to_str(format_info_array.at(f).drm_fourcc); } +PixelFormat find_pixel_format_by_name(const std::string& name) +{ + for (const auto& [fmt, pfi] : format_info_array) { + if (pfi.name == name) + return fmt; + } + + throw invalid_argument("Unsupported pixelformat"); +} + static constexpr uint32_t _div_round_up(uint32_t a, uint32_t b) { return (a + b - 1) / b; |
