Results 1 to 5 of 5

Thread: Rotating pixmap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Rotating pixmap

    Well, finally solved with the QPainter aproximation.

    Qt Code:
    1. //Please note this method takes 2 mseg to finish for a 20x20 pixmap.
    2. QPixmap rotatedPixmap(m_pixOriginal.size());
    3. rotatedPixmap.fill(QColor::fromRgb(0, 0, 0, 0)); //the new pixmap must be transparent.
    4. QPainter* p = new QPainter(&rotatedPixmap);
    5. QSize size = m_pxOriginal.size();
    6. p->translate(size.height()/2,size.height()/2);
    7. p->rotate(m_iAngle);
    8. p->translate(-size.height()/2,-size.height()/2);
    9. p->drawPixmap(0, 0, m_pxOriginal);
    10. p->end();
    11. delete p;
    12. m_pxItem->setPixmap(rotatedPixmap);
    To copy to clipboard, switch view to plain text mode 


    Definitly there is a translation problem when rotating a QPixmap, I don't know if its because the conversion to/from QImage or the known small rotation (according the QtAssistan it's possible to solve it with QPixmap::trueMatrix, but It doesn't solve it in my code) but the pixmap rotation is an issue in Qt.
    Last edited by jano_alex_es; 19th December 2010 at 04:22.

Similar Threads

  1. Rotating Gradient
    By JeffC in forum Newbie
    Replies: 3
    Last Post: 3rd June 2012, 11:11
  2. rotating a widget
    By oguzy in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2008, 00:08
  3. Rotating the polygon
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 4th September 2008, 00:41
  4. Rotating a slider...
    By ACFred in forum Newbie
    Replies: 7
    Last Post: 24th February 2008, 15:56
  5. Rotating QGraphicsItem
    By Gopala Krishna in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2006, 11:50

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
  •  
Qt is a trademark of The Qt Company.