1 Star 0 Fork 0

小喻同学i/YUVReticle

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mainwindow.cpp 2.24 KB
一键复制 编辑 原始数据 按行查看 历史
yuxj 提交于 2024-09-26 19:53 . add
#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();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oweni/yuvreticle.git
git@gitee.com:oweni/yuvreticle.git
oweni
yuvreticle
YUVReticle
master

搜索帮助