繁体   English   中英

Pixmap屏幕截图转换为低质量

[英]Pixmap screenshot convert to low-quality

我正在使用qt creator创建示例远程协助,我的项目有两部分服务器和客户端,客户端正在截取屏幕截图并将其发送到服务器,但是屏幕截图图片的质量很高,而且尺寸太大,因此从中发送它不是一个好主意局域网或互联网协议,我需要调整图像大小或将其转换为低质量,以便几乎可以识别

这是我的截图代码

 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));
 }

看起来您知道如何更改图像大小,为什么还不够?

做就是了:

QPixmap smallPixmap = originalPixmap.scaled( QSize( originalPixmap.size().x()/4, originalPixmap.size().y()/4 ), Qt::KeepAspectRatio,                                                   Qt::SmoothTransformation );

并发送smallPixmap而不是originalPixmap

您还可以(应该)使用QImageWriter压缩图像,这将允许您创建使用jpeg格式压缩的图像,这也可以减少内存使用。

检查一下 ,看起来他们在做什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM