代码拉取完成,页面将自动刷新
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "reticlemanager/yuvreticlemanager.h"
#include <QFile>
#include <QDebug>
const QString BACKGROUND_IMAGE_YUV = ":/icon/back_1024(1024)_768.yuv";
const int BACKGROUND_IMAGE_WIDTH = 1024;
const int BACKGROUND_IMAGE_HEIGTH = 768;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
initConnect();
QFile bgfile(BACKGROUND_IMAGE_YUV);
if (bgfile.open(QIODevice::ReadOnly))
{
QByteArray bgYuvData = bgfile.readAll();
qDebug() << bgfile.size();
size_t size = 1024 * 768 * 3 / 2;
m_bgInfo.yData = new unsigned char[size];
memset(m_bgInfo.yData, 0, sizeof(size));
memcpy(m_bgInfo.yData, bgYuvData.data(), size);
m_bgInfo.w = BACKGROUND_IMAGE_WIDTH;
m_bgInfo.h = BACKGROUND_IMAGE_HEIGTH;
m_bgInfo.stride = BACKGROUND_IMAGE_WIDTH;
m_bgInfo.uData = m_bgInfo.yData + (m_bgInfo.w * m_bgInfo.h);
m_bgInfo.vData = m_bgInfo.uData + (m_bgInfo.w * m_bgInfo.h / 4);
}
YUVReticleManager::getInstance()->setConversionParam(ConversionParam(QSize(1440, 1080), QSize(400, 300)));
YUVReticleManager::getInstance()->setReticleBrightness(5);
YUVReticleManager::getInstance()->setReticleColor(YUV_PEN_COLOR_RED);
YUVReticleManager::getInstance()->slotOriginZoomCenterChanged(QPoint(512 + 4, 384 + 4), 10);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::initConnect()
{
ui->lbl_reticle_type->setText("0");
connect(ui->btn_reticle_style, &QPushButton::clicked, this, &MainWindow::onReticleTypeClickd);
}
void MainWindow::drawReticle()
{
YUVReticleManager::getInstance()->paintReticle(m_bgInfo);
ui->label->setPixmap(QPixmap::fromImage(YuvPainter::I420ToQImage(m_bgInfo.yData, 1024, 768)));
}
void MainWindow::onReticleTypeClickd()
{
static int curType = 0;
curType++;
if (curType > 9) curType = 0;
curType = 3;
ui->lbl_reticle_type->setText(QString::number(curType));
YUVReticleManager::getInstance()->setReticleType(curType);
// YUVReticleManager::getInstance()->setInnerReticleColor(YUV_PEN_COLOR_BLUE);
// YUVReticleManager::getInstance()->setInnerReticleType(0);
drawReticle();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。