Rotate bitmap on canvas in android
<p>I have a problem to rotate bitmap on canvas ,I am drawing bitmap on canvas by using canvas.drawline and use following code to rotate image</p>

<p>It rotate but it shows two image now ?How to remove previous image from canvas? What to do?</p>

<pre><code>bitmap = Bitmap.createBitmap((int) /*getWindowManager()
                        .getDefaultDisplay().getWidth()*/600, (int) /*getWindowManager()
                        .getDefaultDisplay().getHeight()*/600, Bitmap.Config.ARGB_8888 );
             Canvas canvas = new Canvas(bitmap);
             drawingImageView.setVisibility(View.VISIBLE);

               drawingImageView.setImageBitmap(bitmap);

              // canvas.rotate(90);
                   for(int i=0;i&lt;SettingsStaticData.arrX1_crossPoint.size();i++)
                   {

                       canvas.drawLine(new Float(SettingsStaticData.arrX1_crossPoint.get(i)),new Float(SettingsStaticData.arrY1_crossPoint.get(i)),new Float(SettingsStaticData.arrX2_crossPoint.get(i)) ,new Float(SettingsStaticData.arrY2_crossPoint.get(i)), paint);


                   }


                    paint.setStrokeWidth((float) 0.9);
                   paint.setStyle(Paint.Style.FILL);
                 //  paint.setColor(Color.RED);

                   paint.setColor(Color.parseColor("#800080"));
               for(int i=0;i&lt;arrXX.size()-1;i++)
                {

                  if(i==arrXX.size()-2)
                  {
                      canvas.drawLine(new Float(arrXX.get(0)),new Float(arrYY.get(0)),new Float(arrXX.get(i+1)) ,new Float(arrYY.get(i+1)), paint);
                      canvas.drawLine(new Float(arrXX.get(i)),new Float(arrYY.get(i)),new Float(arrXX.get(i+1)) ,new Float(arrYY.get(i+1)), paint);

                  }
                  else
                  {
                      canvas.drawLine(new Float(arrXX.get(i)),new Float(arrYY.get(i)),new Float(arrXX.get(i+1)) ,new Float(arrYY.get(i+1)), paint);

                  }
                }


        //     canvas.drawColor(0, Mode.CLEAR);
               Matrix matrix = new Matrix();

                  matrix.reset();
               matrix.postTranslate(-bitmap.getWidth() / 2-500, -bitmap.getHeight() / 2-500); // Centers image
               matrix.postRotate(180);
              //matrix.postTranslate(px, py);


               canvas.drawBitmap(bitmap, matrix, null);
</code></pre>
