基于Android 实现图片平移、缩放、旋转同时进行

2019-12-10 19:53:20于海丽
  • /**  * 图片缩放矩阵 
  • */  private Matrix matrix = new Matrix(); 
  • /**  * 保存触摸前的图片缩放矩阵 
  • */  private Matrix savedMatrix = new Matrix(); 
  • /**  * 保存触点移动过程中的图片缩放矩阵 
  • */  private Matrix matrix1 = new Matrix(); 
  • /**  * 屏幕高度 
  • */  private int displayHeight; 
  • /**  * 屏幕宽度 
  • */  private int displayWidth; 
  • /**  * 最小缩放比例 
  • */  protected float minScale = 1f; 
  • /**  * 最大缩放比例 
  • */  protected float maxScale = 3f; 
  • /**  * 当前缩放比例 
  • */  protected float currentScale = 1f; 
  • /**  * 多点触摸2个触摸点间的起始距离 
  • */  private float oldDist; 
  • /**  * 多点触摸时图片的起始角度 
  • */  private float oldRotation = 0; 
  • /**  * 旋转角度 
  • */  protected float rotation = 0; 
  • /**  * 图片初始宽度 
  • */  private int imgWidth; 
  • /**  * 图片初始高度 
  • */  private int imgHeight; 
  • /**  * 设置单点触摸退出图片显示时,单点触摸的灵敏度(可针对不同手机单独设置) 
  • */  protected final int MOVE_MAX = 2; 
  • /**  * 单点触摸时手指触发的‘MotionEvent.ACTION_MOVE'次数 
  • */  private int fingerNumMove = 0; 
  • private Bitmap bm;  /** 
  • * 保存matrix缩放比例  */ 
  • private float matrixScale= 1;  /*private String imagePath;*/ 
  • /**  * 显示被存入缓存中的网络图片 
  • *  * @param event 观察者事件