title: Rotating an image more then once
body: <p>I have written some code using eclipse for android application.The following is my  Activity.java class.When I execute my code, the image gets rotated only once and if I click the button again, the image is not  getting rotated and at the same time it is showing me"" 6291456-byte external allocation too large for this process."" error.</p>
  
  <pre><code>import android.app.Activity;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Matrix;
  import android.graphics.drawable.BitmapDrawable;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ImageView;
  
  public class ImageActivity extends Activity implements OnClickListener {
  
      /** Called when the activity is first created. */
      ImageView img;
      Bitmap bmp;
      Bitmap rotatedBMP;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Button button = (Button) findViewById(R.id.button);
          button.setOnClickListener(this);
      }
  
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
          img = (ImageView) findViewById(R.id.imageView01);
          bmp = BitmapFactory.decodeResource(getResources(),R.drawable.bharath);
  
  
          int w = bmp.getWidth();
          int h = bmp.getHeight();
  
          Matrix mtx = new Matrix();
          mtx.preRotate(90);
  
          rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
          img.setImageBitmap(rotatedBMP);
      }
  
  }
  </code></pre>