qpixmap保存图片
时间: 2023-08-06 18:06:33 浏览: 236
QPixmap可以通过调用save()函数来保存图片。例如,可以使用以下代码将QPixmap对象保存为图片文件:
```cpp
QPixmap pixmap(400, 300);
// 绘制图片到pixmap对象
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, 400, 300, QPixmap("C:/Users/Administrator/Desktop/MyQtCode/day04/05_QPixmap/face"));
painter.end();
// 保存图片
pixmap.save("C:/Users/Administrator/Desktop/MyQtCode/day04/05_QPixmap/face11.jpg");
```
这段代码创建了一个大小为400x300的QPixmap对象,并将图片绘制到该对象上。然后使用save()函数将该QPixmap对象保存为名为"face11.jpg"的图片文件。
#### 引用[.reference_title]
- *1* *2* [28黑马QT笔记之QPixmap保存图片](https://blog.csdn.net/weixin_44517656/article/details/105822974)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [基于 Qt 的可视化图片处理程序——图片的加载与保存](https://blog.csdn.net/m0_59161987/article/details/128479118)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文