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 <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kaaira Gupta
2020-07-27 21:51:42 +05:30
committed by Kieran Bingham
parent c4b75cb66c
commit 6b32eebf86
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -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 */