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. How can we know the polygon contains many pixels?
Forum Updated to NodeBB v4.3 + New Features

How can we know the polygon contains many pixels?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.0k 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.
  • H Offline
    H Offline
    hjh2008
    wrote on last edited by
    #1

    I use a list of points to draw a ploygon,and i want to know how many pixels has be contained,what should i do?

    thanks!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Study some math. Qt doesn't help you calculate that, but a fair bit of "Geometry":http://en.wikipedia.org/wiki/Geometry will.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        broadpeak
        wrote on last edited by
        #3

        Your question is a little bit inaccurate and meaningless.
        Exact question please.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          Does "this":http://en.wikipedia.org/wiki/Polygon_triangulation help? Anyway, this is not a Qt related question.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hjh2008
            wrote on last edited by
            #5

            I don't think so,because when i use red brush to draw this polygon,Qt knows which pixel will be red and paint it red,so I think Qt must konws the count of the red pixels! but I don't konw how to get the count.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fluca1978
              wrote on last edited by
              #6

              A QPolygon is a vector of points, so Qt does not know if your polygon is closed or not, and therefore could not know how you want to calculate its surface. At least, this is what I think.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                The fact that Qt can fill your polygon, does not mean that it knows how many pixels are red. Filling doesn't work that way.

                You could of course paint your polygon into a QImage, and can the image line by line to count the number of colored pixels. Not very efficient, but perhaps enough for your goals?

                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