2014-04-21 3 views
0

내 프로그램이 회전 할 때 잘 실행됩니다. & 무제한 확대/축소 또는 회전없이 확대/축소 제한. 그래서, 스케일 값을 변경할 수 및 다음 루프에서, currentScale도 변경됩니다 - 내가 뭔가 잘못 생각으로 maxtrix.postRotate 실행 후Android : 이미지 뷰의 회전 및 제한 확대 사이의 충돌

} else if (mode == ZOOM) { 
      float newDist = spacing(event); 
      matrix.set(savedMatrix); 
      if (newDist > 10f) { 
       float scale = newDist/oldDist; 
       matrix.getValues(mValues1); 
       float currentScale = mValues1[0]; 
       if (currentScale * scale < MIN_ZOOM) { 
        scale = MIN_ZOOM/currentScale; 
       } else if (currentScale * scale > MAX_ZOOM) { 
        scale = MAX_ZOOM/currentScale; 
       } 
       matrix.postScale(scale, scale, mid.x, mid.y); 
       matrix.getValues(mValues1); 
       Log.e("ZOOM", "scale " + mValues1[0]); 
      } 

      /* 
      * uncomment to enable rotating 
      * this function conflicts with zooming limitation 
      */ 
      if (lastEvent != null) { 
       newRot = rotation(event); 
       float r = newRot - d; 
       matrix.postRotate(r, mid.x, mid.y); 
       matrix.getValues(mValues1); 
       Log.e("ROTATE", " scale " + mValues1[0]); 
      } 
     } 

이 mValues1 [0]입니다 : 여기 내 코드의 일부이다 제한 확대 검사가 잘못됩니다. 아이디어를주세요. 어떤 도움을 주셔서 감사합니다 :)

답변

0

다른 방법으로 버그를 해결했습니다. I는 currentScale위한 매트릭스 값을 이용하지 : MotionEvent.ACTION_MOVE

case MotionEvent.ACTION_POINTER_UP: 
     // second finger lifted 
     mode = NONE; 
     lastEvent = null; 
     previousScale *= tempScale; 
     if (previousScale > MAX_ZOOM) 
      previousScale = MAX_ZOOM; 
     else if (previousScale < MIN_ZOOM) 
      previousScale = MIN_ZOOM; 
     break; 

및 경우 :

} else if (mode == ZOOM) { 
      float newDist = spacing(event); 
      matrix.set(savedMatrix); 
      if (newDist > 10f) { 
       tempScale = newDist/oldDist; 
       if (previousScale * tempScale < MIN_ZOOM) { 
        tempScale = MIN_ZOOM/previousScale; 
       } else if (previousScale * tempScale > MAX_ZOOM) { 
        tempScale = MAX_ZOOM/previousScale; 
       } 
       matrix.postScale(tempScale, tempScale, mid.x, mid.y); 
      } 

      if (lastEvent != null) { 
       newRot = rotation(event); 
       float r = newRot - d; 
       matrix.postRotate(r, mid.x, mid.y); 
      } 
     } 

float currentScale = mValues1[0]; 

I는 이하와 같은 다른 글로벌 변수 "previsousScale"를 사용