📄 window.cpp
字号:
#include <qpainter.h>#include <qimage.h>#include <qsocketnotifier.h>#include "window.h"#include "global.h"#include "utils.h"#include "cvt.h"#include "net.h"#include "dec.h"#include "cmv.h"extern int use_cmv;extern struct cmv_data data;extern struct net ns1, ns2;int n = 0;int i1 = 0, i2 = 0;char filename[24];unsigned char raw_buf1[RAW_SIZE];unsigned char raw_buf2[RAW_SIZE];unsigned char yuv_buf[YUV_SIZE];window::window() { setMinimumSize(W*2, H); setMaximumSize(W*2, H); setBackgroundMode(Qt::NoBackground); pRGB1 = new QImage(W, H, 32, 0); pRGB2 = new QImage(W, H, 32, 0); dec_init(); QSocketNotifier *sn1 = new QSocketNotifier(ns1.sock, QSocketNotifier::Read, this); QSocketNotifier *sn2 = new QSocketNotifier(ns2.sock, QSocketNotifier::Read, this); connect(sn1, SIGNAL(activated(int)), this, SLOT(get_data1())); connect(sn2, SIGNAL(activated(int)), this, SLOT(get_data2()));}window::~window() { printf("\n");}void window::paintEvent(QPaintEvent *) { QPainter p(this); p.drawImage(0, 0, *pRGB1); p.drawImage(W, 0, *pRGB2);}void window::get_data1() { if (net_recv(raw_buf1, RAW_SIZE, &ns1) != RAW_SIZE) { fprintf(stderr, "net_recv error\n"); return; } dec_process(raw_buf1, yuv_buf); if (use_cmv) { cmv_process(&data, yuv_buf); cvtc(yuv_buf, pRGB1->bits(), data.map, data.rgb); } else cvt(yuv_buf, pRGB1->bits()); fprintf(stderr, "\r%4d %4d", ++i1, i2); update();}void window::get_data2() { if (net_recv(raw_buf2, RAW_SIZE, &ns2) != RAW_SIZE) { fprintf(stderr, "net_recv error\n"); return; } dec_process(raw_buf2, yuv_buf); if (use_cmv) { cmv_process(&data, yuv_buf); cvtc(yuv_buf, pRGB2->bits(), data.map, data.rgb); } else cvt(yuv_buf, pRGB2->bits()); fprintf(stderr, "\r%4d %4d", i1, ++i2); update();}void window::mousePressEvent(QMouseEvent *e) { if (e->button() != RightButton || i1 <=0 || i2 <= 0) return; ++n; sprintf(filename, "%d_1.raw", n); msave(filename, raw_buf1, RAW_SIZE); sprintf(filename, "%d_2.raw", n); msave(filename, raw_buf2, RAW_SIZE); sprintf(filename, "%d.raw", n); setCaption(filename);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -