in cpp/spectrum/core/proc/ScanlineConversion.cpp [206:235]
inline void _convertDynamicPixel(
const indices::RGB& inputIndices,
const std::uint8_t* const inputPixel,
const indices::Gray& outputIndices,
std::uint8_t* const outputPixel,
const image::Color& backgroundColor) {
const auto red = _extractComponent(
inputPixel,
inputIndices.red,
inputIndices.hasAlpha,
outputIndices.hasAlpha,
inputIndices.alpha,
backgroundColor.red);
const auto green = _extractComponent(
inputPixel,
inputIndices.green,
inputIndices.hasAlpha,
outputIndices.hasAlpha,
inputIndices.alpha,
backgroundColor.green);
const auto blue = _extractComponent(
inputPixel,
inputIndices.blue,
inputIndices.hasAlpha,
outputIndices.hasAlpha,
inputIndices.alpha,
backgroundColor.blue);
outputPixel[outputIndices.gray] = (red + green + blue) / 3;
}