frame: implemented set pixel function

Counterpart to Frame::GetPixel()
This commit is contained in:
itsmattkc
2020-06-13 03:00:41 +10:00
parent 209fb536f5
commit 0c9435c94d
4 changed files with 43 additions and 9 deletions
+27 -9
View File
@@ -67,15 +67,7 @@ Color Color::fromHsv(const float &h, const float &s, const float &v)
Color::Color(const char *data, const PixelFormat::Format &format)
{
OIIO::convert_types(PixelFormat::GetOIIOTypeDesc(format),
data,
PixelFormat::GetOIIOTypeDesc(PixelFormat::PIX_FMT_RGB32F),
data_,
PixelFormat::FormatHasAlphaChannel(format) ? kRGBAChannels : kRGBChannels);
if (!PixelFormat::FormatHasAlphaChannel(format)) {
set_alpha(1.0f);
}
*this = fromData(data, format);
}
Color::Color(const QColor &c)
@@ -202,6 +194,32 @@ float Color::lightness() const
return l;
}
void Color::toData(char *data, const PixelFormat::Format &format) const
{
OIIO::convert_types(PixelFormat::GetOIIOTypeDesc(PixelFormat::PIX_FMT_RGB32F),
data_,
PixelFormat::GetOIIOTypeDesc(format),
data,
PixelFormat::FormatHasAlphaChannel(format) ? kRGBAChannels : kRGBChannels);
}
Color Color::fromData(const char *data, const PixelFormat::Format &format)
{
Color c;
OIIO::convert_types(PixelFormat::GetOIIOTypeDesc(format),
data,
PixelFormat::GetOIIOTypeDesc(PixelFormat::PIX_FMT_RGB32F),
c.data_,
PixelFormat::FormatHasAlphaChannel(format) ? kRGBAChannels : kRGBChannels);
if (!PixelFormat::FormatHasAlphaChannel(format)) {
c.set_alpha(1.0f);
}
return c;
}
QColor Color::toQColor() const
{
QColor c;