像素图屏幕截图转换为低质量
Pixmap screenshot convert to low-quality
我正在使用Qt Creator创建示例远程协助我的项目有 2 部分服务器和客户端客户端截取屏幕截图并将其发送到服务器,但屏幕截图图片必须具有很高的质量,并且占用太多大小,从局域网或Internet协议发送它不是好主意我需要调整图像大小或将其转换为低质量,以便几乎可以识别
这是我的屏幕截图代码
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格式压缩的图像,这也应该减少内存使用量。
检查一下,看起来他们正在做你想做的事情。
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中使用nlohmann从类到json的转换
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 将两位数字转换为低内存表示的最快方法
- 如何在不使用循环的情况下将低字节和高字节的字符数组转换为它们的整数数组
- 将浮点类型转换为两个短字节(高字节和低字节)
- OpenGL精灵绘制质量低
- 采用OpenCV的低质量空中缝合
- 使用OpenAL记录尽可能低的质量
- 将有符号整数转换为二进制浮点数,比反运算成本低
- 像素图屏幕截图转换为低质量