SmartLockerTools/Analyser/VideoFrameProvider.cpp

27 lines
778 B
C++
Raw Permalink Normal View History

2024-06-13 15:41:40 +08:00
#include "VideoFrameProvider.h"
VideoFrameProvider::VideoFrameProvider()
2024-09-25 18:44:04 +08:00
: QQuickImageProvider(QQuickImageProvider::Image), m_image(600, 800, QImage::Format_RGB32) {
2024-06-13 15:41:40 +08:00
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() {
2024-09-25 18:44:04 +08:00
m_image = QImage(600, 800, QImage::Format_RGB32);
2024-06-13 15:41:40 +08:00
m_image.fill(Qt::black);
}