title: how to find xy coordinate of pixel in pixel array from android bitmap
body: <p>i have an int array derived from a bitmap using the Bitmap.getPixels() method. This method populates the array with the pixels from the Bitmap. How can i get the xy coordinate of each pixel when i loop through that array? thanks in advance Mat.</p>
  
  <p>[update]
  Thanks for the math. i've tried the following code. i've a bitmap where i've changed the first 50000 pixels to white. i now want to iterate through the bitmap and change all the white pixels to red. atm there is just one red line through the block of white pixels at the top of the bitmap. have you any ideas? thanks alot.</p>
  
  <pre><code>int length = bgr.getWidth()*bgr.getHeight();
                      int[] pixels = new int[length];
                      bgr.getPixels(pixels,0,bgr.getWidth(),0,0,bgr.getWidth(),bgr.getHeight());
                      for (int i=0;i&lt;50000;i++){
                      // If the bitmap is in ARGB_8888 format
  
                          pixels[i] = Color.WHITE;//0xffffffff;
  
                        }
  
                      bgr.setPixels(pixels,0,bgr.getWidth(),0,0,bgr.getWidth(),bgr.getHeight());
  
  
  
  
                          int t = 0;
                      int y  = t / bgr.getWidth();
                      int x = t - (y * bgr.getWidth());
  
                    for( t = 0; t &lt; length; t++){
  
                        int pixel = bgr.getPixel(x,y);
  
                        if(pixel == Color.WHITE){
  
                            bgr.setPixel(x,y,Color.RED);
                            x++;y++;
                        }
                    }
  </code></pre>