summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/multimedia/qdeclarativecamera_p.h7
-rw-r--r--src/imports/multimedia/qdeclarativecameraexposure.cpp34
-rw-r--r--src/imports/multimedia/qdeclarativecameraexposure_p.h12
-rw-r--r--src/multimedia/camera/qcameraexposure.cpp27
-rw-r--r--src/multimedia/camera/qcameraexposure.h3
-rw-r--r--src/multimedia/controls/qcameraexposurecontrol.cpp4
-rw-r--r--src/multimedia/controls/qcameraexposurecontrol.h1
-rw-r--r--src/plugins/simulator/camera/simulatorcameraexposurecontrol.cpp19
-rw-r--r--src/plugins/simulator/camera/simulatorcameraexposurecontrol.h1
-rw-r--r--tests/auto/unit/qcamera/tst_qcamera.cpp13
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h21
11 files changed, 137 insertions, 5 deletions
diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h
index 7004f7e58..6de84f05f 100644
--- a/src/imports/multimedia/qdeclarativecamera_p.h
+++ b/src/imports/multimedia/qdeclarativecamera_p.h
@@ -104,6 +104,7 @@ class QDeclarativeCamera : public QObject, public QDeclarativeParserStatus
Q_ENUMS(FlashMode)
Q_ENUMS(ExposureMode)
+ Q_ENUMS(MeteringMode)
Q_ENUMS(FocusMode)
Q_ENUMS(FocusPointMode)
@@ -164,6 +165,12 @@ public:
ExposureModeVendor = QCameraExposure::ExposureModeVendor
};
+ enum MeteringMode {
+ MeteringMatrix = QCameraExposure::MeteringMatrix,
+ MeteringAverage = QCameraExposure::MeteringAverage,
+ MeteringSpot = QCameraExposure::MeteringSpot
+ };
+
enum FocusMode {
FocusManual = QCameraFocus::ManualFocus,
FocusHyperfocal = QCameraFocus::HyperfocalFocus,
diff --git a/src/imports/multimedia/qdeclarativecameraexposure.cpp b/src/imports/multimedia/qdeclarativecameraexposure.cpp
index 5eca87ca9..79d939e83 100644
--- a/src/imports/multimedia/qdeclarativecameraexposure.cpp
+++ b/src/imports/multimedia/qdeclarativecameraexposure.cpp
@@ -253,7 +253,41 @@ void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCamera::ExposureMod
\fn void QDeclarativeCameraExposure::exposureModeChanged(QDeclarativeCamera::ExposureMode)
*/
+/*!
+ \qmlproperty QPointF CameraExposure::spotMeteringPoint
+ \property QDeclarativeCameraExposure::spotMeteringPoint
+
+ The relative frame coordinates of the point to use for exposure metering (in relative
+ frame coordinates). This point is only used in spot metering mode, and typically defaults
+ to the center \c (0.5, 0.5).
+ */
+
+QPointF QDeclarativeCameraExposure::spotMeteringPoint() const
+{
+ return m_exposure->spotMeteringPoint();
+}
+
+void QDeclarativeCameraExposure::setSpotMeteringPoint(const QPointF &point)
+{
+ QPointF oldPoint(spotMeteringPoint());
+ m_exposure->setSpotMeteringPoint(point);
+ if (oldPoint != spotMeteringPoint())
+ emit spotMeteringPointChanged(spotMeteringPoint());
+}
+
+QDeclarativeCamera::MeteringMode QDeclarativeCameraExposure::meteringMode() const
+{
+ return QDeclarativeCamera::MeteringMode(m_exposure->meteringMode());
+}
+
+void QDeclarativeCameraExposure::setMeteringMode(QDeclarativeCamera::MeteringMode mode)
+{
+ QDeclarativeCamera::MeteringMode oldMode = meteringMode();
+ m_exposure->setMeteringMode(QCameraExposure::MeteringMode(mode));
+ if (oldMode != meteringMode())
+ emit meteringModeChanged(meteringMode());
+}
QT_END_NAMESPACE
diff --git a/src/imports/multimedia/qdeclarativecameraexposure_p.h b/src/imports/multimedia/qdeclarativecameraexposure_p.h
index bd2788fcd..127e62384 100644
--- a/src/imports/multimedia/qdeclarativecameraexposure_p.h
+++ b/src/imports/multimedia/qdeclarativecameraexposure_p.h
@@ -78,6 +78,9 @@ class QDeclarativeCameraExposure : public QObject
Q_PROPERTY(QDeclarativeCamera::ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
+ Q_PROPERTY(QPointF spotMeteringPoint READ spotMeteringPoint WRITE setSpotMeteringPoint NOTIFY spotMeteringPointChanged)
+ Q_PROPERTY(QDeclarativeCamera::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode NOTIFY meteringModeChanged)
+
public:
~QDeclarativeCameraExposure();
@@ -92,6 +95,12 @@ public:
qreal manualShutterSpeed() const;
qreal manualAperture() const;
+ QPointF spotMeteringPoint() const;
+ void setSpotMeteringPoint(const QPointF &point);
+
+ QDeclarativeCamera::MeteringMode meteringMode() const;
+ void setMeteringMode(QDeclarativeCamera::MeteringMode mode);
+
public Q_SLOTS:
void setExposureMode(QDeclarativeCamera::ExposureMode);
void setExposureCompensation(qreal ev);
@@ -116,6 +125,9 @@ Q_SIGNALS:
void exposureCompensationChanged(qreal);
void exposureModeChanged(QDeclarativeCamera::ExposureMode);
+ void meteringModeChanged(QDeclarativeCamera::MeteringMode);
+ void spotMeteringPointChanged(QPointF);
+
private:
friend class QDeclarativeCamera;
QDeclarativeCameraExposure(QCamera *camera, QObject *parent = 0);
diff --git a/src/multimedia/camera/qcameraexposure.cpp b/src/multimedia/camera/qcameraexposure.cpp
index 5c75ad9e2..a618fa317 100644
--- a/src/multimedia/camera/qcameraexposure.cpp
+++ b/src/multimedia/camera/qcameraexposure.cpp
@@ -312,6 +312,33 @@ void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
}
/*!
+ \property QCameraExposure::spotMeteringPoint
+
+ When supported, this property is the (normalized) position of the point of the image
+ where exposure metering will be performed. This is typically used to indicate an
+ "interesting" area of the image that should be exposed properly.
+
+ The coordinates are relative frame coordinates:
+ QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center,
+ which is typically the default spot metering point.
+
+ The spot metering point is only used with spot metering mode.
+ \since 1.1
+ */
+
+QPointF QCameraExposure::spotMeteringPoint() const
+{
+ return d_func()->exposureControl ? d_func()->exposureControl->exposureParameter(QCameraExposureControl::SpotMeteringPoint).toPointF() : QPointF();
+}
+
+void QCameraExposure::setSpotMeteringPoint(const QPointF &point)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::SpotMeteringPoint, point);
+}
+
+
+/*!
Returns true if the metering \a mode is supported.
\since 1.1
*/
diff --git a/src/multimedia/camera/qcameraexposure.h b/src/multimedia/camera/qcameraexposure.h
index 088e7c036..96350a9c1 100644
--- a/src/multimedia/camera/qcameraexposure.h
+++ b/src/multimedia/camera/qcameraexposure.h
@@ -120,6 +120,9 @@ public:
bool isMeteringModeSupported(MeteringMode mode) const;
+ QPointF spotMeteringPoint() const;
+ void setSpotMeteringPoint(const QPointF &point);
+
int isoSensitivity() const;
QList<int> supportedIsoSensitivities(bool *continuous = 0) const;
diff --git a/src/multimedia/controls/qcameraexposurecontrol.cpp b/src/multimedia/controls/qcameraexposurecontrol.cpp
index 4a6f655f8..cd54a1b77 100644
--- a/src/multimedia/controls/qcameraexposurecontrol.cpp
+++ b/src/multimedia/controls/qcameraexposurecontrol.cpp
@@ -133,7 +133,6 @@ QCameraExposureControl::~QCameraExposureControl()
\since 1.1
*/
-
/*!
\fn bool QCameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
Returns true if the metering \a mode is supported.
@@ -162,6 +161,9 @@ QCameraExposureControl::~QCameraExposureControl()
This value is only used in the \l{QCameraExposure::FlashManual}{manual flash mode}.
\value FlashCompensation
Flash compensation, specified as qreal EV value.
+ \value SpotMeteringPoint
+ The relative frame coordinate of the point to use for exposure metering
+ in spot metering mode, specified as a QPointF.
\value ExtendedExposureParameter
The base value for platform specific extended parameters.
For such parameters the sequential values starting from ExtendedExposureParameter shuld be used.
diff --git a/src/multimedia/controls/qcameraexposurecontrol.h b/src/multimedia/controls/qcameraexposurecontrol.h
index ff60784bf..1574bf5b4 100644
--- a/src/multimedia/controls/qcameraexposurecontrol.h
+++ b/src/multimedia/controls/qcameraexposurecontrol.h
@@ -72,6 +72,7 @@ public:
ExposureCompensation = 4,
FlashPower = 5,
FlashCompensation = 6,
+ SpotMeteringPoint = 7,
ExtendedExposureParameter = 1000
};
diff --git a/src/plugins/simulator/camera/simulatorcameraexposurecontrol.cpp b/src/plugins/simulator/camera/simulatorcameraexposurecontrol.cpp
index 1ee820d8c..f4de0dba9 100644
--- a/src/plugins/simulator/camera/simulatorcameraexposurecontrol.cpp
+++ b/src/plugins/simulator/camera/simulatorcameraexposurecontrol.cpp
@@ -48,6 +48,7 @@ SimulatorCameraExposureControl::SimulatorCameraExposureControl(SimulatorCameraSe
QCameraExposureControl(parent),
mExposureMode(QCameraExposure::ExposureAuto),
mMeteringMode(QCameraExposure::MeteringAverage),
+ mSpot(0.5, 0.5),
mSession(session),
mSettings(0)
{
@@ -138,6 +139,7 @@ bool SimulatorCameraExposureControl::isParameterSupported(ExposureParameter para
case QCameraExposureControl::Aperture:
case QCameraExposureControl::ShutterSpeed:
case QCameraExposureControl::ExposureCompensation:
+ case QCameraExposureControl::SpotMeteringPoint:
return true;
case QCameraExposureControl::FlashPower:
case QCameraExposureControl::FlashCompensation:
@@ -161,6 +163,10 @@ QVariant SimulatorCameraExposureControl::exposureParameter(ExposureParameter par
return QVariant(shutterSpeed());
case QCameraExposureControl::ExposureCompensation:
return QVariant(exposureCompensation());
+
+ case QCameraExposureControl::SpotMeteringPoint:
+ return mSpot;
+
case QCameraExposureControl::FlashPower:
case QCameraExposureControl::FlashCompensation:
// Not supported
@@ -303,6 +309,16 @@ bool SimulatorCameraExposureControl::setExposureParameter(ExposureParameter para
case QCameraExposureControl::FlashCompensation:
return false;
+ case QCameraExposureControl::SpotMeteringPoint:
+ {
+ static QRectF valid(0, 0, 1, 1);
+ if (valid.contains(value.toPointF())) {
+ mSpot = value.toPointF();
+ return true;
+ }
+ return false;
+ }
+
default:
// Not supported
return false;
@@ -324,7 +340,8 @@ QString SimulatorCameraExposureControl::extendedParameterName(ExposureParameter
return QString("Flash Power");
case QCameraExposureControl::FlashCompensation:
return QString("Flash Compensation");
-
+ case QCameraExposureControl::SpotMeteringPoint:
+ return QString("Spot Metering Point");
default:
return QString();
}
diff --git a/src/plugins/simulator/camera/simulatorcameraexposurecontrol.h b/src/plugins/simulator/camera/simulatorcameraexposurecontrol.h
index 5e00a6d44..5b7067b77 100644
--- a/src/plugins/simulator/camera/simulatorcameraexposurecontrol.h
+++ b/src/plugins/simulator/camera/simulatorcameraexposurecontrol.h
@@ -116,6 +116,7 @@ private: // Internal - Implementing ExposureParameter
private: // Data
QCameraExposure::ExposureMode mExposureMode;
QCameraExposure::MeteringMode mMeteringMode;
+ QPointF mSpot;
SimulatorCameraSession *mSession;
SimulatorCameraSettings *mSettings;
};
diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp
index 8f52e9fa3..5334c5244 100644
--- a/tests/auto/unit/qcamera/tst_qcamera.cpp
+++ b/tests/auto/unit/qcamera/tst_qcamera.cpp
@@ -235,6 +235,10 @@ void tst_QCamera::testSimpleCameraExposure()
cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
+ cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.5f));
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
+
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
cameraExposure->setExposureCompensation(2.0);
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
@@ -626,6 +630,15 @@ void tst_QCamera::testCameraExposure()
cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringSpot);
+ cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.25f));
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
+ cameraExposure->setSpotMeteringPoint(QPointF(0.25f, 56.3f));
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
+ cameraExposure->setSpotMeteringPoint(QPointF(0, 0));
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0, 0));
+ cameraExposure->setSpotMeteringPoint(QPointF(1, 1));
+ QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(1, 1));
+
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
cameraExposure->setExposureCompensation(2.0);
QCOMPARE(cameraExposure->exposureCompensation(), 2.0);
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
index d89762d43..8a7074085 100644
--- a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
+++ b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
@@ -56,7 +56,8 @@ public:
m_meteringMode(QCameraExposure::MeteringMatrix),
m_exposureCompensation(0),
m_exposureMode(QCameraExposure::ExposureAuto),
- m_flashMode(QCameraExposure::FlashAuto)
+ m_flashMode(QCameraExposure::FlashAuto),
+ m_spot(0.5, 0.5)
{
m_isoRanges << 100 << 200 << 400 << 800;
m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0;
@@ -106,6 +107,7 @@ public:
case QCameraExposureControl::ISO:
case QCameraExposureControl::Aperture:
case QCameraExposureControl::ShutterSpeed:
+ case QCameraExposureControl::SpotMeteringPoint:
return true;
default:
return false;
@@ -123,6 +125,8 @@ public:
return QVariant(m_aperture);
case QCameraExposureControl::ShutterSpeed:
return QVariant(m_shutterSpeed);
+ case QCameraExposureControl::SpotMeteringPoint:
+ return QVariant(m_spot);
default:
return QVariant();
}
@@ -234,6 +238,17 @@ public:
}
}
break;
+
+ case QCameraExposureControl::SpotMeteringPoint:
+ {
+ static QRectF valid(0, 0, 1, 1);
+ if (valid.contains(value.toPointF())) {
+ m_spot = value.toPointF();
+ return true;
+ }
+ return false;
+ }
+
default:
return false;
}
@@ -264,8 +279,7 @@ public:
{
return mode == QCameraExposure::MeteringAverage
|| mode == QCameraExposure::MeteringMatrix
- || mode == QCameraExposure::MeteringAverage
- || mode ==QCameraExposure::MeteringSpot;
+ || mode == QCameraExposure::MeteringSpot;
}
private:
@@ -277,6 +291,7 @@ private:
QCameraExposure::ExposureMode m_exposureMode;
QCameraExposure::FlashModes m_flashMode;
QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res;
+ QPointF m_spot;
};
#endif // MOCKCAMERAEXPOSURECONTROL_H