From 6b32eebf861f9553853a71f1775253459654e56d Mon Sep 17 00:00:00 2001 From: Kaaira Gupta Date: Mon, 27 Jul 2020 21:51:42 +0530 Subject: libcamera: pixel_format: Add a function to return format based on string Add a function which retrieves pixel format corresponding to its name from PixelFormatInfo. Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/libcamera/pixel_format.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp index 14addb51..54763fbf 100644 --- a/src/libcamera/pixel_format.cpp +++ b/src/libcamera/pixel_format.cpp @@ -130,4 +130,15 @@ std::string PixelFormat::toString() const return info.name; } +/** + * \brief Create a PixelFormat from a string + * \return Pixel format + * \return The PixelFormat represented by the \a name if known, or an + * invalid pixel format otherwise. + */ +PixelFormat PixelFormat::fromString(const std::string &name) +{ + return PixelFormatInfo::info(name).format; +} + } /* namespace libcamera */ -- cgit v1.2.1