コード例 #1
0
void ColorSource::initialize_from_spectrum(const ColorEntity& color_entity)
{
    const ColorValueArray& values = color_entity.get_values();

    if (values.empty())
    {
        m_scalar = ScalarInput(0.0);
        m_linear_rgb.set(0.0f);
        m_spectrum.set(0.0f);
        return;
    }

    m_scalar = static_cast<ScalarInput>(values[0]);

    m_spectrum.resize(Spectrum::Samples);
    spectral_values_to_spectrum(
        color_entity.get_wavelength_range()[0],
        color_entity.get_wavelength_range()[1],
        values.size(),
        &values[0],
        &m_spectrum[0]);

    // todo: this should be user-settable.
    const LightingConditions lighting_conditions(
        IlluminantCIED65,
        XYZCMFCIE196410Deg);

    m_linear_rgb = m_spectrum.convert_to_rgb(lighting_conditions);
}
コード例 #2
0
void ColorSource::initialize_from_spectrum(
    const ColorEntity&      color_entity)
{
    const ColorValueArray& values = color_entity.get_values();

    if (values.size() > 0)
    {
        // todo: this should be user-settable.
        const LightingConditions lighting_conditions(
            IlluminantCIED65,
            XYZCMFCIE196410Deg);

        m_scalar = static_cast<double>(values[0]);

        m_spectrum =
            spectral_values_to_spectrum(
                color_entity.get_wavelength_range(),
                values);

        m_linear_rgb =
            ciexyz_to_linear_rgb(
                spectrum_to_ciexyz<float>(lighting_conditions, m_spectrum));
    }
    else
    {
        m_scalar = 0.0;
        m_linear_rgb.set(0.0f);
        m_spectrum.set(0.0f);
    }
}