Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
bgr888.cpp
Go to the documentation of this file.
2
3namespace Haio::Codecs {
4
5/**
6 * @addtogroup move
7 * @{
8 */
9/** blue first and the alpha dropped, which is a tga or a bmp scanline */
10template <>
11Result<void> Move<Color::RGBA8888, Color::BGR888>(Bytes src, std::span<uint8_t> dst, Size size) {
12 const auto pixels = static_cast<size_t>(size.width) * static_cast<size_t>(size.height);
13 if (src.size() < pixels * 4 || dst.size() < pixels * 3) {
14 HAIO_FAIL(InvalidInput, "rgba8888 to bgr888 got a buffer that is too small");
15 }
16
17 for (size_t at = 0, to = 0; at < pixels * 4; at += 4, to += 3) {
18 dst[to + 0] = src[at + 2];
19 dst[to + 1] = src[at + 1];
20 dst[to + 2] = src[at + 0];
21 }
22 return {};
23}
24/** @} */
25
26/**
27 * @addtogroup convert
28 * @{
29 */
30template <>
32 return convertVia<Color::RGBA8888, Color::BGR888>(std::move(src));
33}
34/** @} */
35
36}
Result< Image< Color::BGR888 > > Convert< Color::RGBA8888, Color::BGR888 >(Image< Color::RGBA8888 > src)
Definition bgr888.cpp:31
Result< void > Move< Color::RGBA8888, Color::BGR888 >(Bytes src, std::span< uint8_t > dst, Size size)
Definition bgr888.cpp:11
#define HAIO_FAIL(why, message)
Result< Image< To > > convertVia(Image< From > src)
std::expected< T, Error > Result
std::span< const uint8_t > Bytes