From bee41150afc46f32e7bdfb8605900e754add1e1d Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Tue, 3 Sep 2019 20:19:09 +0800 Subject: [PATCH] .temp.: parse compressed image. --- client/tp-player/mainwindow.cpp | 46 ++++++++++++++++++++++++++------- client/tp-player/mainwindow.h | 9 +++++-- client/tp-player/mainwindow.ui | 15 ----------- client/tp-player/tp-player.qrc | 1 - 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/client/tp-player/mainwindow.cpp b/client/tp-player/mainwindow.cpp index 2259562..1410c6f 100644 --- a/client/tp-player/mainwindow.cpp +++ b/client/tp-player/mainwindow.cpp @@ -5,6 +5,7 @@ #include #include #include +#include bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompressed, uint8_t* dat, uint32_t len) { switch(bitsPerPixel) { @@ -29,6 +30,19 @@ bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompresse free(_dat); 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); free(_dat); } @@ -56,6 +70,7 @@ MainWindow::MainWindow(QWidget *parent) : m_show_bg = true; m_bg = QImage(":/tp-player/res/bg"); m_pt_normal = QImage(":/tp-player/res/cursor.png"); + m_update_img = false; qDebug() << m_pt_normal.width() << "x" << m_pt_normal.height(); @@ -71,11 +86,11 @@ MainWindow::MainWindow(QWidget *parent) : // setWindowFlags(Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint | windowFlags()); //#endif //__APPLE__ - setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮 - //setFixedSize(this->width(),this->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*))); } @@ -102,9 +117,11 @@ void MainWindow::paintEvent(QPaintEvent *) } else { - 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); - //qDebug() << "draw pt (" << m_pt.x << "," << m_pt.y << ")"; - painter.drawImage(m_pt.x, m_pt.y, m_pt_normal); + 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); + else + //qDebug() << "draw pt (" << m_pt.x << "," << m_pt.y << ")"; + 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)); + m_update_img = false; update(); //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_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); } @@ -180,7 +200,15 @@ void MainWindow::on_update_data(update_data* dat) { 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) { - 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; diff --git a/client/tp-player/mainwindow.h b/client/tp-player/mainwindow.h index cd593c0..ffde816 100644 --- a/client/tp-player/mainwindow.h +++ b/client/tp-player/mainwindow.h @@ -28,8 +28,6 @@ private slots: private: Ui::MainWindow *ui; QImage m_bg; - QImage m_pt_normal; - QImage m_img_update; //QPixmap m_bg1; bool m_shown; @@ -37,8 +35,15 @@ private: bool m_show_bg; TS_RECORD_HEADER m_rec_hdr; + + bool m_update_img; + + QImage m_pt_normal; 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_y; int m_img_update_w; diff --git a/client/tp-player/mainwindow.ui b/client/tp-player/mainwindow.ui index db843d5..ecdf9ac 100644 --- a/client/tp-player/mainwindow.ui +++ b/client/tp-player/mainwindow.ui @@ -14,21 +14,6 @@ Teleport Replayer - - - - 0 - 0 - 500 - 17 - - - - - - false - - diff --git a/client/tp-player/tp-player.qrc b/client/tp-player/tp-player.qrc index 7b8956f..cccf89b 100644 --- a/client/tp-player/tp-player.qrc +++ b/client/tp-player/tp-player.qrc @@ -1,6 +1,5 @@ - res/logo.png res/bg.png res/cursor.png