如何拷贝一个QPixmap的一块内容到另外一个QPixmap?

xxxyyyuuu 2010-04-23 11:32:35
QPixmap A;
把A上的一块QRect r区域的内容拷贝到QPixmap B上?
谢谢!
...全文
840 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxxyyyuuu 2010-04-24
  • 打赏
  • 举报
回复
QPixmap *sbmp = new QPixmap(QPixmap::fromImage(sourceImage));
QPixmap cpybmp = sbmp->copy(0,0, 100, 100);

QPixmap drawbmp = QPixmap(QSize(100,100));
QPainter drawp(&drawbmp);
drawp.setCompositionMode(QPainter::RasterOp_SourceAndDestination);
drawp.drawPixmap(QPoint(0,0),cpybmp);

cpybmp = sbmp->copy(100,100, 100, 100);
drawp.drawPixmap(QPoint(0,0),cpybmp);

drawbmp.save("c:\\aaa.bmp");
tingsking18 2010-04-24
  • 打赏
  • 举报
回复
QPixmap QPixmap::copy ( const QRect & rectangle = QRect() ) const
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle. For more information on deep copies, see the Implicit Data Sharing documentation.
If the given rectangle is empty, the whole image is copied.
MicroSky2813 2010-04-24
  • 打赏
  • 举报
回复
不知道使用qpaint画个行不,没试过……

16,216

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧