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. Need help optimizing the design of an image editor program

Need help optimizing the design of an image editor program

Scheduled Pinned Locked Moved Unsolved General and Desktop
qimageqpixmapqlabelimageimage processin
2 Posts 2 Posters 1.5k Views
  • 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.
  • W Offline
    W Offline
    Wings
    wrote on 21 Jun 2016, 10:28 last edited by Wings
    #1

    I am creating an image editor where I perform pixel manipulations to a QImage object, and use a QPixmap (displayed through a QLabel) to represent the changes made to the QImage. The reason why I am using two separate objects for the image is that the QLabel is resizable (to offer the user a better view), and hence, the QPixmap may not be the exact representation of the image. For a better explanation of the relationship between the objects, see the following diagram:

    please enable images

    Therefore, this is what is happening in my program:

    • The user performs mouse movements over the QLabel, in order to edit the image.
    • The x, y coordinates of the mouse events are used to determine the particular pixel of the QPixmap (the resized image).
    • The pixel's x, y values and the resize factor of the QPixmap are used to determine the target pixel of the QImage.
    • The target pixel is modified.
    • A new QPixmap is created from the modified QImage, which is then used to replace the old one.

    As you can probably guess, this design is pretty slow. It won't be a big issue for smaller images, but for larger images I need to speed things up. How do I do it? How do programs like Photoshop achieve this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      archqt
      wrote on 11 Aug 2016, 21:07 last edited by
      #2

      Hi,
      QPainter can draw a QImage. So you can for example create a new Widget, subclass for QLabel for example if you want and reimplement paintEvent. Like this you work all the time with your QImage without creating another one.
      And better you can only update the region that changed, no need to refresh everything. I did not try it but it should work.
      Sincerely

      1 Reply Last reply
      0

      • Login

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