如何从 QImage (Qt 4.6) 中裁剪多边形(用多图像填充)
OS::win xp sp3
Qt::4.6
我正在开发基于 Qt 框架的 PUZZLE 游戏,需要一些帮助。
项目中包含主图片,需要将其分解为更小的部分(具有属于它们的图像的多边形)。因此,我制作图像 QImage image = QImage("someImage.jpg")
并希望在该对象上进行诸如裁剪图像之类的操作。
我检查了 QImage
、QPixmap
... 诺基亚网站上的文档,寻找成员函数。与裁剪类似,但发现为零。
需要参考类我必须使用( #include
)来解决这个问题,然后我将重新检查在线文档。
OS::win xp sp3
Qt::4.6
I am working on the PUZZLE game based on Qt framework and need some help.
In project is included main picture which needs to be disassembled to smaller parts (polygons with images belongig to them). So I make image QImage image = QImage("someImage.jpg")
and want to operate with something like croping image on that object.
I checked QImage
, QPixmap
... docu on nokia site looking for member func. similar to croping but found zero.
Need reference to class I must use ( #include <???>
) to solve this problem and then I will recheck online docu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设原始图像称为 A。您有一个多边形 P。您想要创建一个较小的图像 B,该图像基本上是 A 被 P“裁剪”的。步骤如下:
请注意,如果 P 的边界矩形不在 P 中,则可以平移绘制器起源。
Supposed the original image is called A. You have a polygon P. You want to create a smaller image B which is basically A "cropped" by P. Here are the steps:
Note that you might translate the painter if the bounding rect of P is not in the origin.
您可以使用 QImage 的这些成员
You may use these members of QImage
您应该使用 QPixMap:使用它您可以将原始图像的全部或部分复制到拼图部分中。通过用透明颜色绘制这些部分,您可以使多边形的外部变得不可见。或者您将 bitBlt(Qt 3 支持成员)与 QImage 一起使用以获得相同的效果。
You should use a QPixMap: With it you can copy all or parts of the original image into your puzzle parts. By painting into these parts with a transparent color you can make the outside of your polyongs invisible. Or you use bitBlt (Qt 3 Support Member) with QImage for the same effect.