boostorg / boostorg/gil

Channel arithmetics

Aperta
#204 2 commenti 0 reazioni 2 assegnatari Rivendicata da @stefanseefeld Vedi su GitHub
cat/enhancement cat/feature cat/performance status/need-feedback
Lingua principale
C++
Stelle
199
Fork
171
Merge medio
1g 14h
PR unite (30g)
10

Descrizione

Not really an issue but a following up of the discussion in #191.

# Type conversions / promotions

Let's consider for instance the current implementation of `channel_divides_t`:

```c++
template
struct channel_divides_t {
ChannelR operator()(typename channel_traits::const_reference ch1,
typename channel_traits::const_reference ch2) const {
return ChannelR(ch1)/ChannelR(ch2);
}
};
```

The current casting / promotion policy of the channel values is "explicit conversion of operands", but this is problematic for some use cases. Given `ChannelR = int`:

- `int{128} / int{0.8};` (current implementation) gives div by zero.
- `int{128 / d0.8};` gives the expected result.

# Optimization

The current implementation comes with the following warning:

```c++
/// this is a generic implementation; user should specialize it for better performance
```

Does anyone knows what the original authors had in mind?

# Pixel arithmetic operators

I wonder if we could offer pixel arithmetic with operators, something like this:

```c++
template
pixel& operator+(const Pixel& rhs)
{
static_transform(*this, rhs, pixel_plus_t());
return *this;
}
```

Expression templates could be used to remove the temporary values but that may be overkill.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.