AntiClipSettings/VideoFrameProvider.cpp

30 lines
847 B
C++
Raw Permalink Normal View History

2024-08-13 20:06:10 +08:00
#include "VideoFrameProvider.h"
VideoFrameProvider::VideoFrameProvider()
: QQuickImageProvider(QQuickImageProvider::Image), m_image(1280, 720, QImage::Format_RGB32) {
m_image.fill(Qt::black);
}
QImage VideoFrameProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) {
Q_UNUSED(id);
2024-08-21 09:26:06 +08:00
if (id == "black") {
m_image.fill(Qt::black);
}
2024-08-13 20:06:10 +08:00
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(1280, 720, QImage::Format_RGB32);
m_image.fill(Qt::black);
}