boostorg / gil

Boost.GIL - Generic Image Library | Requires C++14 since Boost 1.80
https://boostorg.github.io/gil
Boost Software License 1.0
178 stars 164 forks source link

Alpha-blending #728

Open SergMariaDB opened 1 year ago

SergMariaDB commented 1 year ago

Is your feature request related to a problem? Please describe.

Alpha-blending seem chellengable for this enormous support of the different types of channels.

Describe the solution you'd like

How about start on support the same RGB views?

C++ Example

template auto alpha_blend(const ViewT& view1, const ViewT& view2, ptr_diff_t x=0, ptr_diff_t y=0){ ... }

#include <boost/gil.hpp>
namespace gil = boost::gil;
int main
{
    ...
    auto v3 = alpha_blend(v1, v2);
    ...
}

Describe alternatives you've considered

I imagine using boost::compute for this.

Additional context

https://stackoverflow.com/questions/746899/how-to-calculate-an-rgb-colour-by-specifying-an-alpha-blending-amount

mloskot commented 1 year ago

How about start on support the same RGB views?

There is nothing wrong with features specific or limited to narrow set of specific pixel/view types. Starting small with a proof of concept, well tested, documented...it's actually a common and appreciated practice, and not only in GIL, I guess.

ohhmm commented 1 year ago

Consider it for GSOC. Thanks.

SergMariaDB commented 1 year ago

Found one alpha-blending implementation for boost::gil here https://github.com/boost-gil/gil-contributions-archive/blob/sandbox/boost/gil/extension/toolbox/blend.hpp

Here's boost::compute based image generation sample: https://github.com/ohhmm/generator/blob/5ecaa727352d34fd0b0f134c9b8ceed4a202f475/picture-pattern-generate/generator.cpp#L55

Any plans to use boost::compute for boost::gil?

mloskot commented 1 year ago

Yes, the github.com/boost-gill is our sister org. I forgot there are some blending implementations indeed.

Any plans to use boost::compute for boost::gil?

No plans, AFAIK, but it's possible:

GIL can accept variety of features via extensions, including domain-specific features, features with new dependencies, features with non-Boost externals as dependencies. So, I'd suggest to consider the Boost.Compute-based blending as an extension first. It is easy to move features from extension to core, but once a feature is in core, then removing it is not easy. See more on core vs extensions https://github.com/boostorg/gil/discussions/668