.temp.: parse compressed image.

pull/175/head^2
Apex Liu 2019-09-03 20:19:09 +08:00
parent 0b020810b2
commit bee41150af
4 changed files with 44 additions and 27 deletions

View File

@ -5,6 +5,7 @@
#include <QMatrix> #include <QMatrix>
#include <QDebug> #include <QDebug>
#include <QPainter> #include <QPainter>
#include <QDesktopWidget>
bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompressed, uint8_t* dat, uint32_t len) { bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompressed, uint8_t* dat, uint32_t len) {
switch(bitsPerPixel) { switch(bitsPerPixel) {
@ -29,6 +30,19 @@ bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompresse
free(_dat); free(_dat);
return false; return false;
} }
// static bool first = true;
// if(first) {
// first = false;
// int total_bytes = w*h*2;
// for(int i = 0; i < total_bytes; i++) {
// printf("%02x ", _dat[i]);
// if(i != 0 && i % 16 == 0)
// printf("\n");
// }
// fflush(stdout);
// }
out = QImage(_dat, w, h, QImage::Format_RGB16); out = QImage(_dat, w, h, QImage::Format_RGB16);
free(_dat); free(_dat);
} }
@ -56,6 +70,7 @@ MainWindow::MainWindow(QWidget *parent) :
m_show_bg = true; m_show_bg = true;
m_bg = QImage(":/tp-player/res/bg"); m_bg = QImage(":/tp-player/res/bg");
m_pt_normal = QImage(":/tp-player/res/cursor.png"); m_pt_normal = QImage(":/tp-player/res/cursor.png");
m_update_img = false;
qDebug() << m_pt_normal.width() << "x" << m_pt_normal.height(); qDebug() << m_pt_normal.width() << "x" << m_pt_normal.height();
@ -71,11 +86,11 @@ MainWindow::MainWindow(QWidget *parent) :
// setWindowFlags(Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint | windowFlags()); // setWindowFlags(Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint | windowFlags());
//#endif //__APPLE__ //#endif //__APPLE__
setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
//setFixedSize(this->width(),this->height()); // 禁止拖动窗口大小
resize(m_bg.width(), m_bg.height()); resize(m_bg.width(), m_bg.height());
setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
setFixedSize(m_bg.width(), m_bg.height()); // 禁止拖动窗口大小
connect(&m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(on_update_data(update_data*))); connect(&m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(on_update_data(update_data*)));
} }
@ -102,7 +117,9 @@ void MainWindow::paintEvent(QPaintEvent *)
} }
else { else {
if(m_update_img)
painter.drawImage(m_img_update_x, m_img_update_y, m_img_update, 0, 0, m_img_update_w, m_img_update_h, Qt::AutoColor); painter.drawImage(m_img_update_x, m_img_update_y, m_img_update, 0, 0, m_img_update_w, m_img_update_h, Qt::AutoColor);
else
//qDebug() << "draw pt (" << m_pt.x << "," << m_pt.y << ")"; //qDebug() << "draw pt (" << m_pt.x << "," << m_pt.y << ")";
painter.drawImage(m_pt.x, m_pt.y, m_pt_normal); painter.drawImage(m_pt.x, m_pt.y, m_pt_normal);
} }
@ -138,6 +155,7 @@ void MainWindow::on_update_data(update_data* dat) {
} }
memcpy(&m_pt, dat->data_buf() + sizeof(TS_RECORD_PKG), sizeof(TS_RECORD_RDP_POINTER)); memcpy(&m_pt, dat->data_buf() + sizeof(TS_RECORD_PKG), sizeof(TS_RECORD_RDP_POINTER));
m_update_img = false;
update(); update();
//update(m_pt.x - 8, m_pt.y - 8, 32, 32); //update(m_pt.x - 8, m_pt.y - 8, 32, 32);
} }
@ -158,9 +176,11 @@ void MainWindow::on_update_data(update_data* dat) {
m_img_update_w = info->destRight - info->destLeft + 1; m_img_update_w = info->destRight - info->destLeft + 1;
m_img_update_h = info->destBottom - info->destTop + 1; m_img_update_h = info->destBottom - info->destTop + 1;
qDebug() << "img " << ((info->format == TS_RDP_IMG_BMP) ? "+" : " ") << " (" << m_img_update_x << "," << m_img_update_y << "), [" << m_img_update.width() << "x" << m_img_update.height() << "]"; static int count = 0;
qDebug() << count << "img " << ((info->format == TS_RDP_IMG_BMP) ? "+" : " ") << " (" << m_img_update_x << "," << m_img_update_y << "), [" << m_img_update.width() << "x" << m_img_update.height() << "]";
count++;
m_update_img = true;
update(m_img_update_x, m_img_update_y, m_img_update_w, m_img_update_h); update(m_img_update_x, m_img_update_y, m_img_update_w, m_img_update_h);
} }
@ -180,7 +200,15 @@ void MainWindow::on_update_data(update_data* dat) {
qDebug() << "resize (" << m_rec_hdr.basic.width << "," << m_rec_hdr.basic.height << ")"; qDebug() << "resize (" << m_rec_hdr.basic.width << "," << m_rec_hdr.basic.height << ")";
if(m_rec_hdr.basic.width > 0 && m_rec_hdr.basic.height > 0) { if(m_rec_hdr.basic.width > 0 && m_rec_hdr.basic.height > 0) {
resize(m_rec_hdr.basic.width, m_rec_hdr.basic.height); m_win_board_w = frameGeometry().width() - geometry().width();
m_win_board_h = frameGeometry().height() - geometry().height();
setFixedSize(m_rec_hdr.basic.width + m_win_board_w, m_rec_hdr.basic.height + m_win_board_h);
resize(m_rec_hdr.basic.width + m_win_board_w, m_rec_hdr.basic.height + m_win_board_h);
// QDesktopWidget *desktop = QApplication::desktop(); // =qApp->desktop();也可以
// //move((desktop->width() - this->width())/2, (desktop->height() - this->height())/2);
// move(10, (desktop->height() - this->height())/2);
} }
QString title; QString title;

View File

@ -28,8 +28,6 @@ private slots:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QImage m_bg; QImage m_bg;
QImage m_pt_normal;
QImage m_img_update;
//QPixmap m_bg1; //QPixmap m_bg1;
bool m_shown; bool m_shown;
@ -37,8 +35,15 @@ private:
bool m_show_bg; bool m_show_bg;
TS_RECORD_HEADER m_rec_hdr; TS_RECORD_HEADER m_rec_hdr;
bool m_update_img;
QImage m_pt_normal;
TS_RECORD_RDP_POINTER m_pt; TS_RECORD_RDP_POINTER m_pt;
QImage m_img_update;
int m_win_board_w;
int m_win_board_h;
int m_img_update_x; int m_img_update_x;
int m_img_update_y; int m_img_update_y;
int m_img_update_w; int m_img_update_w;

View File

@ -14,21 +14,6 @@
<string>Teleport Replayer</string> <string>Teleport Replayer</string>
</property> </property>
<widget class="QWidget" name="centralWidget"/> <widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>17</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusBar">
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
</widget>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>

View File

@ -1,6 +1,5 @@
<RCC> <RCC>
<qresource prefix="/tp-player"> <qresource prefix="/tp-player">
<file>res/logo.png</file>
<file>res/bg.png</file> <file>res/bg.png</file>
<file>res/cursor.png</file> <file>res/cursor.png</file>
</qresource> </qresource>