pixelformat: added convenience function for whether a format is float or not

This commit is contained in:
itsmattkc
2020-04-04 13:46:12 +11:00
parent 666bd64943
commit dfb00d9f15
2 changed files with 26 additions and 0 deletions
+21
View File
@@ -48,6 +48,27 @@ bool PixelFormat::FormatHasAlphaChannel(const PixelFormat::Format &format)
return false;
}
bool PixelFormat::FormatIsFloat(const PixelFormat::Format &format)
{
switch (format) {
case PixelFormat::PIX_FMT_RGB16F:
case PixelFormat::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGB32F:
case PixelFormat::PIX_FMT_RGBA32F:
return true;
case PixelFormat::PIX_FMT_RGB8:
case PixelFormat::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGB16U:
case PixelFormat::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
break;
}
return false;
}
OIIO::TypeDesc::BASETYPE PixelFormat::GetOIIOTypeDesc(const PixelFormat::Format &format)
{
switch (format) {
+5
View File
@@ -114,6 +114,11 @@ public:
*/
static bool FormatHasAlphaChannel(const Format& format);
/**
* @brief Simple convenience function returning whether a pixel format is float-based or integer-based
*/
static bool FormatIsFloat(const Format& format);
/**
* @brief Get corresponding OpenImageIO TypeDesc for a given pixel format
*/