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. QGraphicsItem: get pixels of drawn items
Qt 6.11 is out! See what's new in the release blog

QGraphicsItem: get pixels of drawn items

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • BlackEyedLionB Offline
    BlackEyedLionB Offline
    BlackEyedLion
    wrote on last edited by
    #1

    I want to draw a line (QLine, QLineF or QGraphicsLineItem) on a QGraphicsView. How can I get information about the pixels that are covered by the line? (Please note that the line might be dashed or have a certain width so I do not mean just the pixels in between the endpoints.) Iterating over all pixels of the whole QGraphicsView (or better the bounding rect) might take a long time. Qt should know these pixels because it has to tell the QGraphicsScene to update them.

    I use PyQt but an answer for Qt might also help me.

    Thank you!

    jsulmJ 1 Reply Last reply
    0
    • BlackEyedLionB BlackEyedLion

      I want to draw a line (QLine, QLineF or QGraphicsLineItem) on a QGraphicsView. How can I get information about the pixels that are covered by the line? (Please note that the line might be dashed or have a certain width so I do not mean just the pixels in between the endpoints.) Iterating over all pixels of the whole QGraphicsView (or better the bounding rect) might take a long time. Qt should know these pixels because it has to tell the QGraphicsScene to update them.

      I use PyQt but an answer for Qt might also help me.

      Thank you!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @BlackEyedLion Hi!
      Why do you need this information?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      BlackEyedLionB 1 Reply Last reply
      0
      • jsulmJ jsulm

        @BlackEyedLion Hi!
        Why do you need this information?

        BlackEyedLionB Offline
        BlackEyedLionB Offline
        BlackEyedLion
        wrote on last edited by
        #3

        @jsulm
        I need to know the color of each pixel to do some image processing calculations. Therefore I want to record the colors in a list - at the beginning for the whole image, later for those pixels that were changed by drawing the line. Of course, I can iterate over all pixels in the image and get their color but that is slow; for a 1 million pixels image it takes about 1.8 seconds on my computer. Iterating over the entries of a 1 million entries list and reading the recorded color from there takes only about 0.2 seconds. I read that the QImage.scanLine function improves the performance but I have not tried it up to now.

        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