Skip to content

Commit

Permalink
examples: fix the Qt example screen is not clear
Browse files Browse the repository at this point in the history
Resize the widget to after client init success; set depth as 32 and create QImage with RGBA8888 format in order to make the vnc display more clear.

Log: fix the Qt example screen is not clear.
  • Loading branch information
re2zero committed Oct 24, 2024
1 parent f7735c4 commit 9a8604f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions examples/client/qt5client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void VncViewer::finishedFramebufferUpdateStatic(rfbClient *cl)

void VncViewer::finishedFramebufferUpdate(rfbClient *cl)
{
m_image = QImage(cl->frameBuffer, cl->width, cl->height, QImage::Format_RGB16);
m_image = QImage(cl->frameBuffer, cl->width, cl->height, QImage::Format_RGBA8888);

update();
}
Expand All @@ -85,22 +85,23 @@ void VncViewer::paintEvent(QPaintEvent *event)
void VncViewer::start()
{
cl = rfbGetClient(8, 3, 4);
cl->format.depth = 24;
cl->format.depth = 16;
cl->format.bitsPerPixel = 16;
cl->format.redShift = 11;
cl->format.greenShift = 5;
cl->format.blueShift = 0;
cl->format.redMax = 0x1f;
cl->format.greenMax = 0x3f;
cl->format.blueMax = 0x1f;
cl->appData.compressLevel = 9;
cl->appData.qualityLevel = 1;
cl->appData.encodingsString = "tight ultra";
cl->format.depth = 32;
// cl->format.depth = 16;
// cl->format.bitsPerPixel = 16;
// cl->format.redShift = 11;
// cl->format.greenShift = 5;
// cl->format.blueShift = 0;
// cl->format.redMax = 0x1f;
// cl->format.greenMax = 0x3f;
// cl->format.blueMax = 0x1f;
// cl->appData.compressLevel = 9;
// cl->appData.qualityLevel = 1;
// cl->appData.encodingsString = "tight ultra";
cl->appData.forceTrueColour = TRUE;
cl->appData.useRemoteCursor = FALSE;
cl->FinishedFrameBufferUpdate = finishedFramebufferUpdateStatic;
cl->serverHost = strdup(serverIp.c_str());
cl->serverPort = serverPort;
cl->appData.useRemoteCursor = TRUE;

rfbClientSetClientData(cl, nullptr, this);

Expand All @@ -110,6 +111,9 @@ void VncViewer::start()
return;
}

std::cout << "[INFO] screen size: " << cl->width << " x " << cl->height << std::endl;
this->resize(cl->width, cl->height);

m_vncThread = new std::thread([this]() {
while (true) {
int i = WaitForMessage(cl, 500);
Expand Down

0 comments on commit 9a8604f

Please sign in to comment.