Reputation: 921
I want to implement a pixel perfect collision detector between two or more QGraphicsItem
. The QGraphicsItem
class provides a collision detector using QPainterPath
objects, so now I want to load an image from file to a QPainterPath
with only non-transparent pixels (make an accurate shape of non-transparent pixels), in this way I can use QGraphicsItem
's own collision detector to implement a pixel perfect collision detector. I wanted to know if there is any way to do this trick??
Upvotes: 1
Views: 157
Reputation: 96
You can use QGraphicsPixmapItem when using images with alpha channel. Use
QGraphicsPixmapItem::shapeMode(QGraphicsPixmapitem::MaskShape)
This extracts a mask based on alpha channel for creating shape.
Upvotes: 1