我正在使用qt创建者创建示例远程协助,我的项目有2部分服务器和客户端,客户端进行屏幕截图并将其发送到服务器,但是屏幕快照必须具有很高的质量,而且它的大小太大,从局域网或因特网协议发送它不是个好主意,我需要调整图像大小或将其转换为低质量,这样几乎可以识别
这是我的截图代码
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));
}发布于 2016-07-10 18:56:20
看起来你知道如何改变图像大小,为什么这还不够?
只要做:
QPixmap smallPixmap = originalPixmap.scaled( QSize( originalPixmap.size().x()/4, originalPixmap.size().y()/4 ), Qt::KeepAspectRatio, Qt::SmoothTransformation );并发送smallPixmap而不是originalPixmap。
您也可以(应该)使用QImageWriter压缩图像,这将允许您创建一个使用jpeg格式压缩的映像,这也会减少内存的使用。
查一下这个,看起来他们做的都是你想做的。
https://stackoverflow.com/questions/38295120
复制相似问题