123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #include "ImageProvider.h"
- #include <QDebug>
- 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<uint8_t> &pBuffer, int32_t ,
- int32_t ) {
-
- if (pBuffer == nullptr)
- {
- // m_image.fill(Qt::GlobalColor::transparent);
- return;
- }
- std::lock_guard<std::mutex> l(buffer_lock_);
-
- m_pImgProvider->img = QImage(pBuffer.get(), 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;
- }
-
- }
- 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;
- }
- }
- }
|