i'm using qt creator to create sample Remote Assistance my project have 2 part server and client the client taking screenshot and send it to server but screenshot pictures have to much quality and it take too much size and is not good idea to send it from local area network or internet protocol i need to resize image size or convert it to low quality so that can be almost Recognizable
this is my screenshot codes
void MainWindow::shootScreen()
{
originalPixmap = QPixmap(); // clear image for low memory situations
// on embedded devices.
originalPixmap = QGuiApplication::primaryScreen()->grabWindow(0);
//emit getScreen(originalPixmap);
updateScreenshotLabel();
}
void MainWindow::updateScreenshotLabel()
{
this->ui->label_2->setPixmap(originalPixmap.scaled(this->ui->label_2- >size(),
Qt::KeepAspectRatio,
Qt::SmoothTransformation));
}
Looks like you know how to change an image size, why isn't that enough?
Just do:
QPixmap smallPixmap = originalPixmap.scaled( QSize( originalPixmap.size().x()/4, originalPixmap.size().y()/4 ), Qt::KeepAspectRatio, Qt::SmoothTransformation );
And send smallPixmap
instead of originalPixmap
.
You could (should) also compress the image using QImageWriter, this will allow you to create an image compressed with jpeg format, which should also reduce the memory usage.
Check this, looks like they do what you are trying to do.