diff options
author | Simon Rettberg | 2018-07-20 15:41:45 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-20 15:41:45 +0200 |
commit | e354df7172efbe25e94f1c6ae5516912dad1d114 (patch) | |
tree | dab58ddbeb78743ebad07669d932d475ac5ba5df /src/server/net/client.cpp | |
parent | [client] Don't activateWindow VNC viewer on open in multiscreen mode (diff) | |
download | pvs2-e354df7172efbe25e94f1c6ae5516912dad1d114.tar.gz pvs2-e354df7172efbe25e94f1c6ae5516912dad1d114.tar.xz pvs2-e354df7172efbe25e94f1c6ae5516912dad1d114.zip |
[server] Resize thumbs server side on mismatch
The server requests the appropriate size thumbnail from the client so no
bandwidth will be wasted. However, due to privacy concerns, the client
might actually send a thumb that's smaller than requested, resulting in
a tiny thumbnail on the server with huge gray borders. The server will
now scale up the image in those cases.
We'd actually also scale the image down now if it were too large, but
this doesn't happen under normal circumstances.
Diffstat (limited to 'src/server/net/client.cpp')
-rw-r--r-- | src/server/net/client.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 0dd8783..c11cb63 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -104,7 +104,7 @@ void Client::removeAttentionInternal() } /******************************************************************************/ -void Client::requestThumb(const int width, const int height) +void Client::requestThumb(const QSize& size) { if (_socket->state() != QAbstractSocket::ConnectedState) { qDebug("requestThumb called in bad state"); @@ -112,8 +112,8 @@ void Client::requestThumb(const int width, const int height) } NetworkMessage msgTmb; msgTmb.setField(_ID, _THUMB); - msgTmb.setField(_X, QString::number(width)); - msgTmb.setField(_Y, QString::number(height)); + msgTmb.setField(_X, QString::number(size.width())); + msgTmb.setField(_Y, QString::number(size.height())); msgTmb.writeMessage(_socket); } @@ -154,16 +154,15 @@ void Client::handleMsg() if (_authed == 2) { // Following messages are only valid of the client is already authenticated if (id == _THUMB) { - QPixmap pixmap; - const QByteArray& rawImage = _fromClient.getFieldBytes("IMG"); + QImage image; + _rawRemoteScreen = _fromClient.getFieldBytes("IMG"); /* size 0 means the client is in exam-mode and therefore doesn't send any thumbnail */ - if (rawImage.size() > 0) { - if (!pixmap.loadFromData(rawImage)) { + if (_rawRemoteScreen.size() > 0) { + if (!image.loadFromData(_rawRemoteScreen)) { qDebug("Could not decode thumbnail image from client."); return; } - _rawRemoteScreen = QByteArray(rawImage); - emit thumbUpdated(this, pixmap, rawImage); + emit thumbUpdated(this, image); } } else if (id == _VNCSERVER) { // Client tells about startup of vnc server |