pixelformat: added convenience functions for determining the format equivalent with and without an alpha channel
This commit is contained in:
@@ -164,6 +164,52 @@ PixelFormat::Format PixelFormat::OIIOFormatToOliveFormat(OIIO::TypeDesc desc, bo
|
||||
return PixelFormat::PIX_FMT_INVALID;
|
||||
}
|
||||
|
||||
PixelFormat::Format PixelFormat::GetFormatWithAlphaChannel(PixelFormat::Format f)
|
||||
{
|
||||
switch (f) {
|
||||
case PIX_FMT_INVALID:
|
||||
case PIX_FMT_COUNT:
|
||||
break;
|
||||
case PIX_FMT_RGB8:
|
||||
case PIX_FMT_RGBA8:
|
||||
return PIX_FMT_RGBA8;
|
||||
case PIX_FMT_RGB16U:
|
||||
case PIX_FMT_RGBA16U:
|
||||
return PIX_FMT_RGBA16U;
|
||||
case PIX_FMT_RGB16F:
|
||||
case PIX_FMT_RGBA16F:
|
||||
return PIX_FMT_RGBA16F;
|
||||
case PIX_FMT_RGB32F:
|
||||
case PIX_FMT_RGBA32F:
|
||||
return PIX_FMT_RGBA32F;
|
||||
}
|
||||
|
||||
return PIX_FMT_INVALID;
|
||||
}
|
||||
|
||||
PixelFormat::Format PixelFormat::GetFormatWithoutAlphaChannel(PixelFormat::Format f)
|
||||
{
|
||||
switch (f) {
|
||||
case PIX_FMT_INVALID:
|
||||
case PIX_FMT_COUNT:
|
||||
break;
|
||||
case PIX_FMT_RGB8:
|
||||
case PIX_FMT_RGBA8:
|
||||
return PIX_FMT_RGB8;
|
||||
case PIX_FMT_RGB16U:
|
||||
case PIX_FMT_RGBA16U:
|
||||
return PIX_FMT_RGB16U;
|
||||
case PIX_FMT_RGB16F:
|
||||
case PIX_FMT_RGBA16F:
|
||||
return PIX_FMT_RGB16F;
|
||||
case PIX_FMT_RGB32F:
|
||||
case PIX_FMT_RGBA32F:
|
||||
return PIX_FMT_RGB32F;
|
||||
}
|
||||
|
||||
return PIX_FMT_INVALID;
|
||||
}
|
||||
|
||||
int PixelFormat::GetBufferSize(const PixelFormat::Format &format, const int &width, const int &height)
|
||||
{
|
||||
return BytesPerPixel(format) * width * height;
|
||||
|
||||
@@ -68,6 +68,9 @@ public:
|
||||
|
||||
static Format OIIOFormatToOliveFormat(OIIO::TypeDesc desc, bool has_alpha);
|
||||
|
||||
static Format GetFormatWithAlphaChannel(Format f);
|
||||
static Format GetFormatWithoutAlphaChannel(Format f);
|
||||
|
||||
/**
|
||||
* @brief Returns the minimum buffer size (in bytes) necessary for a given format, width, and height.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user