#include "ImageProvider.h" #include ImageProvider::ImageProvider() : QQuickImageProvider(QQuickImageProvider::Image) {} QImage ImageProvider::requestImage(const QString &, QSize *, const QSize &) { return this->img; } QPixmap ImageProvider::requestPixmap(const QString &, QSize *, const QSize &) { return QPixmap::fromImage(this->img); } ShowImage::ShowImage(QObject *parent, RenderPosition _pos) : QObject(parent) { campos = _pos; m_pImgProvider = new ImageProvider(); } void ShowImage::sendFrontImage() { emit callQmlRefeshFrontImg(); } void ShowImage::sendBackImage() { emit callQmlRefeshBackImg(); } void ShowImage::sendLeftImage() { // m_pImgProvider->img = image;// .mirrored(true, false); emit callQmlRefeshLeftImg(); } void ShowImage::sendRightImage() { // m_pImgProvider->img = image;//.mirrored(true, false); emit callQmlRefeshRightImg(); } void ShowImage::sendLeftAnchor() { // m_pImgProvider->img = image; emit callQmlRefeshLeftAnchor(); } void ShowImage::sendRightAnchor() { // m_pImgProvider->img = image; emit callQmlRefeshRightAnchor(); } // void ShowImage::sendPanelImage(QImage sendimage) { // m_pImgProvider->img = sendimage; // emit callQmlRefeshPanelImg(); //} void ShowImage::OnRender(std::unique_ptr &pBuffer, int32_t , int32_t ) { if (pBuffer == nullptr) { // m_image.fill(Qt::GlobalColor::transparent); return; } std::lock_guard l(buffer_lock_); m_pImgProvider->img = QImage(pBuffer.get(), 1280, 720, QImage::Format_RGB32); switch (campos) { case RenderPosition::FRONT: sendFrontImage(); //qDebug() << "11111111111111111"; break; case RenderPosition::LEFT: sendLeftImage(); //qDebug() << "222222222222222222222222"; break; case RenderPosition::RIGHT: sendRightImage(); //qDebug() << "33333333333333333333333333333333"; break; case RenderPosition::BACK: sendBackImage(); //qDebug() << "44444444444444444444444444444444444444"; break; case RenderPosition::LANCHOR: sendLeftAnchor(); //qDebug() << "5555555555555555555555555555555555555555555555555"; break; case RenderPosition::RANCHOR: sendRightAnchor(); //qDebug() << "666666666666666666666666666666666666666666666666666666666666666666666666666"; break; } } void ShowImage::Empty() { if (m_pImgProvider != nullptr) { //QColor bmpBackA(0, 0, 0, 0); m_pImgProvider->img = QImage((uint8_t*)NULL, 1280, 720, QImage::Format_RGB32); switch (campos) { case RenderPosition::FRONT: sendFrontImage(); break; case RenderPosition::LEFT: sendLeftImage(); break; case RenderPosition::RIGHT: sendRightImage(); break; case RenderPosition::BACK: sendBackImage(); break; case RenderPosition::LANCHOR: sendLeftAnchor(); break; case RenderPosition::RANCHOR: sendRightAnchor(); break; } } }