2012-09-27 7 views
0

저는 캔버스와 이미지 작업중인 앱에서 현재 작업하고있는 안드로이드 개발을 처음 접했습니다 ... 하지만 프로세스 중간에 멈추었습니다.Android 캔버스 이미지 스케일링

나는 사용자가 이미지의 가장자리에 닿아 그/그녀가 텟 이미지를 드래그하면 이미지가 조정됩니다 이러한 기능을 구현하려면 ..

나는 많이 봤 그것의 더하지만 아무것도 발견을 couldnt 튜토리얼 또는 데모 ..

당신이 도와주세요. 이러한 기능은

enter image description here

답변

0

이것을 시도 ..이 아래 그림처럼 갤럭시 참고로 제공된다.

사용자가 오른쪽에서 이미지를 터치하고 그 오른쪽을 드래그하면 아래 코드가 이미지의 크기를 조절하고 크기가 조절 된 이미지를 그립니다.

Bitmap bmpImage; 
     Rect src = new Rect(); 
     Rect dst = new Rect(); 
     src.left = initial_Start_pos_X; // initial Start X postion of image 
     src.top = initial_Start_pos_Y; // initial Start Y postion of image 
     src.right =initial_End_pos_X; // initial End X postion of image 
     src.bottom = initial_End_pos_Y; // initial End Y postion of image 

     dst.left = initial_Start_pos_X; 
     dst.top = initial_Start_pos_Y; 
     dst.right = Draged_Pox_X;  // Drag X position of image 
     dst.bottom = initial_End_pos_Y; 

     canvas.drawBitmap(bmpImage, src, dst, paint); // This line will scaled the image according to dst rect. It will take the image from src rect and draw in dst rect. so it will scaled the image. 

이미지를 드래그 할 때마다보기를 무효화해야합니다. ONTOUCHMOVE에서보기를 무효화해야합니다.

먼저 확인해야합니다. 사용자가 이미지의 어느면을 터치하고 드래그하면 위의 코드를 수정해야합니다. 위의 코드는 오른쪽에만 크기 조정 된 이미지 만 표시됩니다.