SmartLockerTools/Analyser/VideoFrameProvider.cpp

27 lines
778 B
C++
Raw Normal View History

2024-06-13 15:41:40 +08:00
#include "VideoFrameProvider.h"
VideoFrameProvider::VideoFrameProvider()
: QQuickImageProvider(QQuickImageProvider::Image), m_image(800, 600, QImage::Format_RGB32) {
m_image.fill(Qt::black);
}
QImage VideoFrameProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) {
Q_UNUSED(id);
if (size) *size = m_image.size();
if (requestedSize.width() > 0 && requestedSize.height() > 0)
return m_image.scaled(requestedSize.width(), requestedSize.height(), Qt::KeepAspectRatio);
return m_image;
}
void VideoFrameProvider::setImage(const QImage &image) {
m_image = image;
}
void VideoFrameProvider::reset() {
m_image = QImage(800, 600, QImage::Format_RGB32);
m_image.fill(Qt::black);
}