I'm a little bit confusing about GIL syntax. I want to convert
rgb8_image_t
to
rgba8_image_t
and set alpha channel to 1. Is there any built-in function. If not how to do this manually?
I'm a little bit confusing about GIL syntax. I want to convert
rgb8_image_t
to
rgba8_image_t
and set alpha channel to 1. Is there any built-in function. If not how to do this manually?
Copyright © 2021 Jogjafile Inc.
You want to use
boost::gil::copy_and_convert_pixels
with a suitable matchingcolor_convert
specialisation in scope.Here's a complete example:
Alternatively there are
copy_and_convert_pixels
overloads (see the docs) which accept an explicit color conversion functor, but for something as uncontroversial as making RGB images have an implicit max alpha on conversion there seems to be little reason not to define it where it will be picked up by default.