Solved QImage::pixelColor: coordinate (XX,XX) out of range
-
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!
-
@small_bird Can you show the code where you call pixelColor? Else it is impossible to say what happens...
-
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.
-
This post is deleted! -
@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. -
@jsulm Thanks a lot! The problem has been solved!