}
checkView();
centerAndRotate();
imageView.setImageMatrix(matrix);
System.out.println("MotionEvent--ACTION_UP");
fingerNumMove = 0;
break;
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
System.out.println("MotionEvent--ACTION_POINTER_UP");
break;
case MotionEvent.ACTION_MOVE:
operateMove(event);
imageView.setImageMatrix(matrix1);
fingerNumMove++;
System.out.println("MotionEvent--ACTION_MOVE");
break;
}
return true;
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
if (bm != null & !bm.isRecycled()) {
bm.recycle(); // 回收图片所占的内存
System.gc(); // 提醒系统及时回收
}
}
/**
* 显示图片
*/
private void showImage() {
imgWidth = bm.getWidth();
imgHeight = bm.getHeight();
mImageView.setImageBitmap(bm);
matrix.setScale(1, 1);
centerAndRotate();
mImageView.setImageMatrix(matrix);
}
/**
* 触点移动时的操作
*
* @param event 触摸事件
*/
private void operateMove(MotionEvent event) {
matrix1.set(savedMatrix);
switch (mode) {
case DRAG:
matrix1.postTranslate(event.getX() - point0.x, event.getY() - point0.y);
break;
case ZOOM:
rotation = rotation(event) - oldRotation;
float newDist = spacing(event);
float scale = newDist / oldDist;
currentScale = (scale > 3.5f) ? 3.5f : scale;
System.out.println("缩放倍数---" + currentScale);
System.out.println("旋转角度---" + rotation);
/** 縮放 */
matrix1.postScale(currentScale, currentScale, pointM.x, pointM.y);