#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) { //qDebug() <<&pBuffer; if (pBuffer == nullptr) { // m_image.fill(Qt::GlobalColor::transparent); return; } std::lock_guard l(buffer_lock_); //m_pImgProvider->img = QImage(pBuffer.get(), 1920, 1080, QImage::Format_RGB32); //m_pImgProvider->img = QImage(pBuffer.get(), 1280, 720, QImage::Format_RGB32); m_pImgProvider->img = QImage(pBuffer.get(), 1080, 640, QImage::Format_RGB32); switch (campos) { case RenderPosition::FRONT: //m_CountF++; //if (m_CountF % 3 == 0) { sendFrontImage(); //qDebug() << "====·¢ËÍ1/3ÊÓƵ" << "======="; } 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; } } 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); //m_pImgProvider->img = QImage((uint8_t*)NULL, 1920, 1080, QImage::Format_RGB32); m_pImgProvider->img = QImage((uint8_t*)NULL, 1080, 640, 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; } } }