title: How to display bitmap pixel by pixel in Android?
body: <p>I am trying to display a bitmap image pixel by pixel (which explicitly means with some delay).<br />
  For that I am using two &quot;for-loops&quot;, but it prints only a single row of pixels...</p>
  <p>My code:</p>
  <pre><code>Button start = (Button) findViewById(R.id.start);
  start.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          //Toast.makeText(getBaseContext(), &quot;Printing...&quot;, Toast.LENGTH_SHORT).show();
          iImageArray = new int[bMap.getWidth()* bMap.getHeight()];                                   //initializing the array for the image size
          bMap.getPixels(iImageArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight());   //copy pixel data from the Bitmap into the 'intArray' array  
               
          //Canvas canvas = new Canvas (bMap);
          //replace the red pixels with yellow ones  
          for (int i=0; i &lt; bMap.getHeight(); i++) {  
              for(int j=0; j&lt;bMap.getWidth(); j++) {
                  iImageArray[j] = 0xFFFFFFFF;
              } 
          } 
          bMap = Bitmap.createBitmap(iImageArray, bMap.getWidth(), bMap.getHeight(), Bitmap.Config.ARGB_8888);//Initialize the bitmap, with the replaced color
          image.setImageBitmap(bMap);
          //canvas.drawPoints(iImageArray, 0, bMap.getHeight()*bMap.getWidth(), paint);
      }
  });
  </code></pre>
  <p>And I want to print the bitmap in grayscale and for that I found this code...</p>
  <pre><code>public Bitmap toGrayscale(Bitmap bmpOriginal) {        
      int width, height;
      height = bmpOriginal.getHeight();
      width = bmpOriginal.getWidth();    
  
      Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
      Canvas c = new Canvas(bmpGrayscale);
      Paint paint = new Paint();
      ColorMatrix cm = new ColorMatrix();
      cm.setSaturation(0);
  
      ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
      paint.setColorFilter(f);
  
      c.drawBitmap(bmpOriginal, 0, 0, paint);
  
      return bmpGrayscale;
  }
  </code></pre>
  <p>It is <code>iImageArray[i] = 0xFFFFFFFF;</code> that I have to test, not the actual grayscale value...</p>