title: image blur in android (getting error)
body: <p>hi i m trying to implement image blur in android i fond so many example for it but i m trying with this code </p>
  
  <pre><code>private Bitmap getBlurBitmap(Bitmap bitmap, int radius)
      {
          int w,h,total;
  
          if(bitmap == null){
              System.err.println(" &lt;== BitMap is Null ==&gt; ");
              return null;
          }
  
          w=bitmap.getWidth();
          h=bitmap.getHeight();
  
           for (int y = 0; y &lt; h; ++y) {
               for (int x = 0; x &lt; w; ++x) {
                   total = 0;
                   for (int ky = -radius; ky &lt;= radius; ++ky){
                       for (int kx = -radius; kx &lt;= radius; ++kx){
                          // total += source(x + kx, y + ky);
  
                           int _tempx=x + kx;
                           int _tempy=y + ky;
  
                           if(_tempx &lt; 0 )
                               _tempx=0;
                           if(_tempx &gt; w )
                              _tempx = w - kx;
  
                           if(_tempy &lt; 0 )
                               _tempy=0;
                           if(_tempy &gt; h )
                               _tempy = h - ky;
  
                           total += bitmap.getPixel(_tempx, _tempy);
                       }
                   }
                   bitmap.setPixel(x, y,(int)( total / (radius * 2 + 1) ^ 2));
               }
           }
          return bitmap;
      }
  </code></pre>
  
  <p>but whent i try to run this is display <code>FATAL EXCEPTION</code> like</p>
  
  <pre><code>03-18 04:41:54.296: E/AndroidRuntime(16347): FATAL EXCEPTION: main
  03-18 04:41:54.296: E/AndroidRuntime(16347): java.lang.IllegalStateException
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.graphics.Bitmap.setPixel(Bitmap.java:856)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at com.org.PhotoAppSimpleBlureActivity.getBlurBitmap(PhotoAppSimpleBlureActivity.java:81)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at com.org.PhotoAppSimpleBlureActivity.onClick(PhotoAppSimpleBlureActivity.java:93)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.view.View.performClick(View.java:2485)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.view.View$PerformClick.run(View.java:9080)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.os.Handler.handleCallback(Handler.java:587)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.os.Handler.dispatchMessage(Handler.java:92)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.os.Looper.loop(Looper.java:130)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at android.app.ActivityThread.main(ActivityThread.java:3683)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at java.lang.reflect.Method.invoke(Method.java:507)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
  03-18 04:41:54.296: E/AndroidRuntime(16347):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>i don't know what wrong or what i miss,
  can any one help me with this i referred this <a href="http://www.blackpawn.com/texts/blur/default.html" rel="nofollow">Example</a> </p>