Rotate Bitmap about his top

Problems with Canvas, OpenGL, etc...

Rotate Bitmap about his top

Postby Radiance » Sun Jul 17, 2011 12:12 pm

Hi all!
Sorry,my English is bad.
I want rotate my bitmap about his any top.I do it next way:
Code: Select all
                angle = 1.0f;       
         
                bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.green);

      protected void onDraw(Canvas canvas)
      {
                         
                        canvas.rotate(scale);
         
         canvas.drawBitmap(bitmap1, 0 , 0 ,null);
            
         angle += 1.0f;
         
         invalidate();
                 
                 }




This good work,but i need get it use Matrix.I do it next way:

Code: Select all

         angle = 1.0f;       
         
         bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.green);
         
          protected void onDraw(Canvas canvas)
          {
         
         matrix = new Matrix();
         
         matrix.setRotate(angle, 0 ,0);
         
         bitmap2 = Bitmap.createBitmap(bitmap1, 0, 0,bitmap1.getWidth(),bitmap1.getHeight(), matrix,false);
                  
         canvas.drawBitmap(bitmap2,0,0, null);
               
         angle += 1.0f;
         
         invalidate();
         
      }           
   

This is dont work,like previous example.Bitmep rotating another,Bitmap dont have pivot point.
My problem : How make rotate Bitmap use Matrix,that bitmap rotate about any his point
(for example left top),like first example with rotate canvas.
Radiance
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Jul 17, 2011 11:51 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 3 guests