QT中关于QScreen::blit的理解(已摘抄)

关于blit的理解(ok):
void QScreen::blit ( const QImage & image, const QPoint & topLeft, const QRegion & region ) [virtual]
官方文档:
Copies the given region in the given image to the point specified by topLeft using device coordinates.
意思是把image中的region(矩形列表)区域内容,拷贝到设备坐标中的点topLeft上面。
但是,通过打印代码的log,发现,这样理解容易有误,
有一个例子如下:
在blit中,
const QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); ++i) {
painter.drawImage( rects.at(i), image, QRect(rects.at(i).topLeft()-topLeft, rect
s.at(i).size()) );
}
这里,意思是把image中的所有region块(rects[i]),绘制到设备的rects[i]上面。
rects[i]的左上角坐标是相对于设备的,
topLeft是image相对于设备的左上角,
根据函数drawImage的意思,需要把rects[i]转化为相对于image的坐标,所以要减去topLeft。
综上所述,image包含了region中的许多或者一个矩形块,topLeft是image的左上角相对于设备的坐标。目前的理解就是这样。
另外,image的image.rect()的左上角永远是0,0。因为image本身就没有rect的意义。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值