#include "VideoFrameProvider.h"

VideoFrameProvider::VideoFrameProvider()
    : QQuickImageProvider(QQuickImageProvider::Image), m_image(600, 800, 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(600, 800, QImage::Format_RGB32);
    m_image.fill(Qt::black);
}
