PDA

View Full Version : Fast QPixmap rotation in 90° steps



stryga42
6th January 2020, 11:39
I am building something like an image previewer which loads and displays many jpegs. As usual they may contain EXIF information about orientation. Sure I can use QPixmap::transformed to rotate them but this is not really elegant and fast (conversion to QImage and back, a lot of number crunching in the background).
I found an old thread on this topic: https://development.qt-project.narkive.com/LkvsHvRE/rotating-jpeg-images-by-default but this seemed to end without an implementation.
Performing 90 deg rotations could be done very fast right inside the QPixmap - does Qt provide this, am I just missing something?
Although not a problem it would also be nice to have the EXIF handling wrapped inside Qt (currently I am using libexif and compiling for linux only). I found some old references on QExifImageHeader but it seems not part of Qt5. Is this maybe hidden in some commercial-only licensing schemes?
Many thanks!

d_stranz
6th January 2020, 17:53
Not sure how you are displaying your images, but can you set a transform on your QPainter instance and let the painting system do the rotation?

stryga42
17th January 2020, 04:37
I use QLabel as "container" for images, but painting them directly would also be an option.

ChrisW67
17th January 2020, 09:04
You can paint to a QPixmap and then apply it to the label.