Code example for Matrix

Methods: mapPoints, mapRect, postRotate, postTranslate

0
       dstPs = srcPs.clone();  
       srcRect = new RectF(0, 0, mainBmpWidth, mainBmpHeight);  
       dstRect = new RectF();  
       txtBackgroundRect = new RectF(0 - 5, mainBmpHeight - 5, mainBmpWidth + 5, mainBmpHeight + 10);
          
       matrix = new Matrix();  
          
       paint = new Paint();
        
       paintRect = new Paint();  
       paintRect.setColor(Color.RED);  
       paintRect.setAlpha(100);  
       paintRect.setAntiAlias(true);  
           
       paintFrame = new Paint();  
       paintFrame.setColor(Color.WHITE);  
       paintFrame.setAntiAlias(true);  
       paintFrame.setStyle(Paint.Style.STROKE);
       paintFrame.setStrokeWidth(10); 
           
       setMatrix();   
   }   
    
   public int getBmpWidthWithFrame() 
   { 
	   return (int)(mainBmpWidth + 10);
   } 
    
   public int getBmpHeightWithFrame() 
   { 
	   return (int)(mainBmpHeight + 15);
   } 
    
   public void setImagePath(String imagePath)
   { 
	   this.imagePath = imagePath;
   } 
    
   public void setText(String text)
   { 
   		this.text = text;
   } 
    
   public void setRotateAngel(float angel)
   { 
   		this.angel = angel;	
   } 
       
   private void setMatrix(){   
    	matrix.postTranslate(deltaX , deltaY); 
        matrix.postRotate(angel,dstPs[CTR_MID_MID * 2], dstPs[CTR_MID_MID * 2 + 1]);
        matrix.mapPoints(dstPs, srcPs);  
        matrix.mapRect(dstRect, srcRect);  
         
        System.out.println("srcRect:" + srcRect.toString());
        System.out.println("dstRect:" + dstRect.toString());
   }