Properly use rgba32f_pixel_t

This commit is contained in:
Dan Paulat 2024-07-14 00:10:22 -05:00
parent c7023f9cd2
commit 7659ef0906
3 changed files with 23 additions and 4 deletions

View file

@ -29,6 +29,15 @@ boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString)
static_cast<uint8_t>(qAlpha(color))};
}
boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString)
{
boost::gil::rgba8_pixel_t rgba8Pixel = ToRgba8PixelT(argbString);
return boost::gil::rgba32f_pixel_t {rgba8Pixel[0] / 255.0f,
rgba8Pixel[1] / 255.0f,
rgba8Pixel[2] / 255.0f,
rgba8Pixel[3] / 255.0f};
}
} // namespace color
} // namespace util
} // namespace qt

View file

@ -29,6 +29,16 @@ std::string ToArgbString(const boost::gil::rgba8_pixel_t& color);
*/
boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString);
/**
* Converts an ARGB string used by Qt libraries to a Boost.GIL 32-bit RGBA
* floating point pixel.
*
* @param argbString ARGB string in the format #AARRGGBB
*
* @return RGBA32 floating point pixel
*/
boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString);
} // namespace color
} // namespace util
} // namespace qt