Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPixmap::fromImage() vs QPixmap::toImage()
Forum Updated to NodeBB v4.3 + New Features

QPixmap::fromImage() vs QPixmap::toImage()

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 325 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #1

    I have to read .png (possibly others, but maybe only these) files from disk. I will need a QPixmap from that (for QGraphicsPixmapItem) for use in the application. But I (the end user) will also potentially be manipulating the image in code so I want to keep them around as QImages (from which I will produce a new QPixmap) as well.

    When reading the file initially, does it make any difference whether I do:

    QPixmap::load();
    QPixmap::toImage();
    

    versus

    QImage::load();
    QPixmap::fromImage();
    

    ? I know little about images. Is either direction (a) slower than the other or (b) loses some information in the original .png file?

    Christian EhrlicherC 1 Reply Last reply
    1
    • JonBJ JonB

      I have to read .png (possibly others, but maybe only these) files from disk. I will need a QPixmap from that (for QGraphicsPixmapItem) for use in the application. But I (the end user) will also potentially be manipulating the image in code so I want to keep them around as QImages (from which I will produce a new QPixmap) as well.

      When reading the file initially, does it make any difference whether I do:

      QPixmap::load();
      QPixmap::toImage();
      

      versus

      QImage::load();
      QPixmap::fromImage();
      

      ? I know little about images. Is either direction (a) slower than the other or (b) loses some information in the original .png file?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      An image from a file/buffer is read by QImageReader, therefore into a QImage. Then you can convert it to a QPixmap. On windows and afair on linux there is no real conversation between QImage and QPixmap needed though.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      JonBJ 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        An image from a file/buffer is read by QImageReader, therefore into a QImage. Then you can convert it to a QPixmap. On windows and afair on linux there is no real conversation between QImage and QPixmap needed though.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in QPixmap::fromImage() vs QPixmap::toImage():

        An image from a file/buffer is read by QImageReader, therefore into a QImage.

        Perfect, thanks!

        1 Reply Last reply
        0
        • JonBJ JonB has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved