Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qimagecapture.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCAMERAIMAGECAPTURE_H
5#define QCAMERAIMAGECAPTURE_H
6
7#include <QtCore/qobject.h>
8#include <QtMultimedia/qvideoframe.h>
9
10QT_BEGIN_NAMESPACE
11
12class QSize;
13class QMediaMetaData;
15
17
18class QImageEncoderSettings;
19class QCamera;
21
22class QImageCapturePrivate;
23class Q_MULTIMEDIA_EXPORT QImageCapture : public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY(bool readyForCapture READ isReadyForCapture NOTIFY readyForCaptureChanged)
27 Q_PROPERTY(QMediaMetaData metaData READ metaData WRITE setMetaData NOTIFY metaDataChanged)
28 Q_PROPERTY(Error error READ error NOTIFY errorChanged)
29 Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
30 Q_PROPERTY(FileFormat fileFormat READ fileFormat WRITE setFileFormat NOTIFY fileFormatChanged)
31 Q_PROPERTY(Quality quality READ quality WRITE setQuality NOTIFY qualityChanged)
32 Q_PROPERTY(QList<FileFormat> supportedFormats READ supportedFormats CONSTANT REVISION(6, 10))
33 Q_PROPERTY(QSize resolution READ resolution WRITE setResolution RESET resetResolution NOTIFY
34 resolutionChanged REVISION(6, 13))
35public:
36 enum Error
37 {
38 NoError,
39 NotReadyError,
40 ResourceError,
41 OutOfSpaceError,
42 NotSupportedFeatureError,
43 FormatError
44 };
45 Q_ENUM(Error)
47 enum Quality
48 {
49 VeryLowQuality,
50 LowQuality,
51 NormalQuality,
52 HighQuality,
53 VeryHighQuality
54 };
55 Q_ENUM(Quality)
57 enum FileFormat {
58 UnspecifiedFormat,
59 JPEG,
60 PNG,
61 WebP,
62 Tiff,
63 LastFileFormat = Tiff
64 };
65 Q_ENUM(FileFormat)
66
67 explicit QImageCapture(QObject *parent = nullptr);
68 ~QImageCapture() override;
69
70 bool isAvailable() const;
71
72 QMediaCaptureSession *captureSession() const;
73
74 Error error() const;
75 QString errorString() const;
76
77 bool isReadyForCapture() const;
78
79 FileFormat fileFormat() const;
80 void setFileFormat(FileFormat format);
82 static QList<FileFormat> supportedFormats();
83 static QString fileFormatName(FileFormat c);
84 static QString fileFormatDescription(FileFormat c);
85
86 QSize resolution() const;
87 void setResolution(const QSize &);
88 void setResolution(int width, int height);
89 void resetResolution();
90
91 Quality quality() const;
92 void setQuality(Quality quality);
93
94 QMediaMetaData metaData() const;
95 void setMetaData(const QMediaMetaData &metaData);
96 void addMetaData(const QMediaMetaData &metaData);
97
98public Q_SLOTS:
99 int captureToFile(const QString &location = QString());
100 int capture();
101
102Q_SIGNALS:
103 void errorChanged();
104 void errorOccurred(int id, QImageCapture::Error error, const QString &errorString);
106 void readyForCaptureChanged(bool ready);
107 void metaDataChanged();
109 void fileFormatChanged();
110 void qualityChanged();
111 void resolutionChanged();
113 void imageExposed(int id);
114 void imageCaptured(int id, const QImage &preview);
115 void imageMetadataAvailable(int id, const QMediaMetaData &metaData);
116 void imageAvailable(int id, const QVideoFrame &frame);
117 void imageSaved(int id, const QString &fileName);
118
119private:
120 // This is here to flag an incompatibilities with Qt 5
121 QImageCapture(QCamera *) = delete;
123 friend class QMediaCaptureSession;
124 class QPlatformImageCapture *platformImageCapture();
125 void setCaptureSession(QMediaCaptureSession *session);
126 QImageCapturePrivate *d_ptr;
127 Q_DISABLE_COPY(QImageCapture)
128 Q_DECLARE_PRIVATE(QImageCapture)
129 Q_PRIVATE_SLOT(d_func(), void _q_error(int, int, const QString &))
130};
131
132QT_END_NAMESPACE
133
134#endif
\inmodule QtMultimedia
Combined button and popup list for selecting options.