Results 1 to 2 of 2

Thread: pixmap to polygon

  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default pixmap to polygon

    I'm trying to convert a sprite (QGraphicsPixmapItem) to a polygon (QGraphicsPolygonItem).

    I know Qt creates some kind of boundary region because when the contains() call accurately returns only when I am actually clicking on the item (after I do the mapToScene() call).

    When I try to get the QGraphicsPixmapItem::boundingRegion(QTransform) it crashes. I'm not sure I have the right idea in using this function because why would it accept a transform?

    There's also a QGraphicsPixmapItem method that returns a QPolygonF called "mapToScene". But I don't think that's what I want either since you have to pass a polygon to the QGraphicsPixmapItem to get a polygon back. That doesn't seem to quite make sense for what I'm trying to do.

    I'd eventually like to create a QGraphicsPolygonItem from the QGraphicsPixmapItem coordinates.

    Any ideas?

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: pixmap to polygon

    I dont really understand whta information in your pixmap you want ot convert into a polygon. Is it the boundingRect() or some shape defined by a mask or from colored pixels?

    Anyway, have a look at QPainterPath. This can be the link that fits your needs since this is the return type of QGraphicsItem::opaqueArea and can be constructed with polygons or region

Similar Threads

  1. Qt 4.4 - Problem displaying pixmap in release mode
    By spawn9997 in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2009, 19:40
  2. Rotating the polygon
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 4th September 2008, 00:41
  3. Performance problems with small pixmap
    By RThaden in forum Qt Programming
    Replies: 4
    Last Post: 9th July 2008, 15:14
  4. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  5. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.