Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: fix the Qt example screen is not clear #631

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't move code randomly around and don't leave commented-out code. I'd like to keep the 16 bit for educational purposes - after all, this is just an example. Any other changes to improve here welcome!


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
Loading