Results 1 to 5 of 5

Thread: How to flip QImage

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to flip QImage

    Hi,

    I have a QImage, I need to flip vertically or horizontally or both depending on situation, but I got lost in the QTransform. I can use scanLine and flip myself, but I think QImage::transformed should do the job.

    Can someone please tell me how?

    Thanks

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to flip QImage

    I'm not sure the correct way to use it, but I've done this before:

    Qt Code:
    1. QImage myImage("c:/myimage.png");
    2. QTransform myTransform;
    3. myTransform.rotate(180);
    4. myImage = myImage.transformed(myTransform);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to flip QImage

    There is a simpler way, QImage::mirrored().
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    JimDaniel (9th March 2009)

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to flip QImage

    Which is equivalent to QImage::scaled() with -1 parameter in the axis opposite to the one you want to mirror along.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to flip QImage

    Thanks all!! Great features!

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. QPainter doesn't seem to draw QImage
    By Denarius in forum Qt Programming
    Replies: 7
    Last Post: 3rd March 2009, 14:12
  3. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  4. Vertical Flip of dds Textures
    By ajb_advance in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2008, 11:05
  5. Multiple QPainters on QImage
    By fire in forum Qt Programming
    Replies: 3
    Last Post: 14th August 2008, 13:10

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.