Add a color filter property to QCameraImageProcessing.

[ChangeLog] New color filter property for QCameraImageProcessing.

Change-Id: I999e349e3e4f284b533fa62ba50903fbd21cb400
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
This commit is contained in:
Andrew den Exter
2014-07-09 13:38:25 +10:00
committed by Andrew den Exter
parent be7fef656a
commit 25ad679c25
9 changed files with 212 additions and 7 deletions

View File

@@ -55,6 +55,30 @@ CameraBinImageProcessing::CameraBinImageProcessing(CameraBinSession *session)
m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_TUNGSTEN] = QCameraImageProcessing::WhiteBalanceTungsten;
m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_FLUORESCENT] = QCameraImageProcessing::WhiteBalanceFluorescent;
unlockWhiteBalance();
#if GST_CHECK_VERSION(1, 0, 0)
m_filterMap.insert(QCameraImageProcessing::ColorFilterNone, GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL);
if (m_session->photography()) {
m_filterMap.insert(QCameraImageProcessing::ColorFilterSepia, GST_PHOTOGRAPHY_COLOR_TONE_MODE_SEPIA);
m_filterMap.insert(QCameraImageProcessing::ColorFilterGrayscale, GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRAYSCALE);
m_filterMap.insert(QCameraImageProcessing::ColorFilterNegative, GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEGATIVE);
m_filterMap.insert(QCameraImageProcessing::ColorFilterSolarize, GST_PHOTOGRAPHY_COLOR_TONE_MODE_SOLARIZE);
#if GST_CHECK_VERSION(1, 2, 0)
m_filterMap.insert(QCameraImageProcessing::ColorFilterPosterize, GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE);
m_filterMap.insert(QCameraImageProcessing::ColorFilterWhiteboard, GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD);
m_filterMap.insert(QCameraImageProcessing::ColorFilterBlackboard, GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD);
m_filterMap.insert(QCameraImageProcessing::ColorFilterAqua, GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA);
#endif
}
#else
m_filterMap.insert(QCameraImageProcessing::ColorFilterNone, GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL);
if (m_session->photography()) {
m_filterMap.insert(QCameraImageProcessing::ColorFilterSepia, GST_PHOTOGRAPHY_COLOUR_TONE_MODE_SEPIA);
m_filterMap.insert(QCameraImageProcessing::ColorFilterGrayscale, GST_PHOTOGRAPHY_COLOUR_TONE_MODE_GRAYSCALE);
m_filterMap.insert(QCameraImageProcessing::ColorFilterNegative, GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NEGATIVE);
m_filterMap.insert(QCameraImageProcessing::ColorFilterSolarize, GST_PHOTOGRAPHY_COLOUR_TONE_MODE_SOLARIZE);
}
#endif
#endif
updateColorBalanceValues();
@@ -179,6 +203,14 @@ bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingC
return qAbs(value.toReal()) <= 1.0;
case WhiteBalancePreset:
return isWhiteBalanceModeSupported(value.value<QCameraImageProcessing::WhiteBalanceMode>());
case ColorFilter: {
const QCameraImageProcessing::ColorFilter filter = value.value<QCameraImageProcessing::ColorFilter>();
#ifdef HAVE_GST_PHOTOGRAPHY
return m_filterMap.contains(filter);
#else
return filter == QCameraImageProcessing::ColorFilterNone;
#endif
}
default:
break;
}
@@ -189,12 +221,28 @@ bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingC
QVariant CameraBinImageProcessing::parameter(
QCameraImageProcessingControl::ProcessingParameter parameter) const
{
if (parameter == QCameraImageProcessingControl::WhiteBalancePreset)
switch (parameter) {
case QCameraImageProcessingControl::WhiteBalancePreset:
return QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(whiteBalanceMode());
else if (m_values.contains(parameter))
return m_values.value(parameter);
else
return QVariant();
case QCameraImageProcessingControl::ColorFilter:
#ifdef HAVE_GST_PHOTOGRAPHY
if (GstPhotography *photography = m_session->photography()) {
#if GST_CHECK_VERSION(1, 0, 0)
GstPhotographyColorToneMode mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL;
gst_photography_get_color_tone_mode(photography, &mode);
#else
GstColourToneMode mode = GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL;
gst_photography_get_colour_tone_mode(photography, &mode);
#endif
return QVariant::fromValue(m_filterMap.key(mode, QCameraImageProcessing::ColorFilterNone));
}
#endif
return QVariant::fromValue(QCameraImageProcessing::ColorFilterNone);
default:
return m_values.contains(parameter)
? QVariant(m_values.value(parameter))
: QVariant();
}
}
void CameraBinImageProcessing::setParameter(QCameraImageProcessingControl::ProcessingParameter parameter,
@@ -213,6 +261,21 @@ void CameraBinImageProcessing::setParameter(QCameraImageProcessingControl::Proce
case WhiteBalancePreset:
setWhiteBalanceMode(value.value<QCameraImageProcessing::WhiteBalanceMode>());
break;
case QCameraImageProcessingControl::ColorFilter:
#ifdef HAVE_GST_PHOTOGRAPHY
if (GstPhotography *photography = m_session->photography()) {
#if GST_CHECK_VERSION(1, 0, 0)
gst_photography_set_color_tone_mode(photography, m_filterMap.value(
value.value<QCameraImageProcessing::ColorFilter>(),
GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL));
#else
gst_photography_set_colour_tone_mode(photography, m_filterMap.value(
value.value<QCameraImageProcessing::ColorFilter>(),
GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL));
#endif
}
#endif
break;
default:
break;
}