title: Changing the pixel color in android
body: <pre><code>testButton.setOnClickListener(new Button.OnClickListener(){
  
          @Override
          public void onClick(View v) 
          {
              Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);for (int i = 0; i &lt; mutableBitmap.getWidth(); i++) 
                  {
                      for (int j = 0; j &lt; mutableBitmap.getHeight(); j++) 
                      {
                          int pixel = mutableBitmap.getPixel(i, j);
                          // get red color value
                          int red = Color.red(pixel);
                          int color = Color.argb(0xFF, red, 0, 0);
                          mutableBitmap.setPixel(i, j, color);
                          imageView.setImageBitmap(mutableBitmap);
                      }
                  }
          }
  
  
          });
  </code></pre>
  
  <p>I am trying to change the pixel color with only red value. Therefore i get the red value from a given pixel  and then tried to replace the same pixel with only that red value. The program runs successfully but when i click the button it crashes out. Can anyone tell me what i am doing wrong</p>
  
  <p>LOGCAT error</p>
  
  <pre><code>12-03 15:16:57.228: E/AndroidRuntime(5103): FATAL EXCEPTION: main
  12-03 15:16:57.228: E/AndroidRuntime(5103): java.lang.IllegalStateException
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.graphics.Bitmap.setPixel(Bitmap.java:1002)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at com.example.imaging.AndroidCamera$7.onClick(AndroidCamera.java:216)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.view.View.performClick(View.java:3511)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.view.View$PerformClick.run(View.java:14109)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.os.Handler.handleCallback(Handler.java:605)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.os.Handler.dispatchMessage(Handler.java:92)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.os.Looper.loop(Looper.java:137)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at android.app.ActivityThread.main(ActivityThread.java:4424)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at java.lang.reflect.Method.invokeNative(Native Method
  12-03 15:16:57.228: E/AndroidRuntime(5103): at java.lang.reflect.Method.invoke(Method.java:511)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  12-03 15:16:57.228: E/AndroidRuntime(5103): at dalvik.system.NativeStart.main(Native Method)
  </code></pre>