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. QImage::pixelColor: coordinate (XX,XX) out of range
Forum Update on Monday, May 27th 2025

QImage::pixelColor: coordinate (XX,XX) out of range

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 4.6k 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.
  • small_birdS Offline
    small_birdS Offline
    small_bird
    wrote on last edited by
    #1

    Hello, I got this error when I use the QImage::pixelColor() class:

    QImage::pixelColor: coordinate (-1,1) out of range.
    

    However, I have never used the -1 index. Does anyone know the reason? Thanks in advance!

    jsulmJ 1 Reply Last reply
    0
    • small_birdS small_bird

      Hello, I got this error when I use the QImage::pixelColor() class:

      QImage::pixelColor: coordinate (-1,1) out of range.
      

      However, I have never used the -1 index. Does anyone know the reason? Thanks in advance!

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

      @small_bird Can you show the code where you call pixelColor? Else it is impossible to say what happens...

      small_birdS 1 Reply Last reply
      0
      • jsulmJ jsulm

        @small_bird Can you show the code where you call pixelColor? Else it is impossible to say what happens...

        small_birdS Offline
        small_birdS Offline
        small_bird
        wrote on last edited by
        #3

        @jsulm

                    max=0;
                    min=255;
                    for(int k=i-regionLength;k!=i+regionLength+1;++k)
                    {
                        if(k<0||k>=m_imageTobeProcessed.width())
                        {
                            continue;
                        }
                        if(m_imageTobeProcessed.pixelColor(k,j).blue()<min)
                        {
                            min=m_imageTobeProcessed.pixelColor(k,j).blue();
                        }
                        if(m_imageTobeProcessed.pixelColor(k,j).blue()>max)
                        {
                            max=m_imageTobeProcessed.pixelColor(k,j).blue();
                        }
                        sum+=(m_imageTobeProcessed.pixelColor(k,j).blue());
                    }
        

        As you can see, I want to get the maximal and minimal color value of one image which is sure not to be NULL.

        jsulmJ 2 Replies Last reply
        0
        • small_birdS small_bird

          @jsulm

                      max=0;
                      min=255;
                      for(int k=i-regionLength;k!=i+regionLength+1;++k)
                      {
                          if(k<0||k>=m_imageTobeProcessed.width())
                          {
                              continue;
                          }
                          if(m_imageTobeProcessed.pixelColor(k,j).blue()<min)
                          {
                              min=m_imageTobeProcessed.pixelColor(k,j).blue();
                          }
                          if(m_imageTobeProcessed.pixelColor(k,j).blue()>max)
                          {
                              max=m_imageTobeProcessed.pixelColor(k,j).blue();
                          }
                          sum+=(m_imageTobeProcessed.pixelColor(k,j).blue());
                      }
          

          As you can see, I want to get the maximal and minimal color value of one image which is sure not to be NULL.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • small_birdS small_bird

            @jsulm

                        max=0;
                        min=255;
                        for(int k=i-regionLength;k!=i+regionLength+1;++k)
                        {
                            if(k<0||k>=m_imageTobeProcessed.width())
                            {
                                continue;
                            }
                            if(m_imageTobeProcessed.pixelColor(k,j).blue()<min)
                            {
                                min=m_imageTobeProcessed.pixelColor(k,j).blue();
                            }
                            if(m_imageTobeProcessed.pixelColor(k,j).blue()>max)
                            {
                                max=m_imageTobeProcessed.pixelColor(k,j).blue();
                            }
                            sum+=(m_imageTobeProcessed.pixelColor(k,j).blue());
                        }
            

            As you can see, I want to get the maximal and minimal color value of one image which is sure not to be NULL.

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @small_bird Are you sure you get this warning when executing this code? Do you call pixelColor somewhere else?
            You should debug your app to see when and where exactly this happens.

            small_birdS 1 Reply Last reply
            0
            • jsulmJ jsulm

              @small_bird Are you sure you get this warning when executing this code? Do you call pixelColor somewhere else?
              You should debug your app to see when and where exactly this happens.

              small_birdS Offline
              small_birdS Offline
              small_bird
              wrote on last edited by
              #6

              @jsulm Thanks a lot! The problem has been solved!

              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