2014-10-21 5 views
1

2 개의 이미지에서 파노라마보기 인 Windows Phone 8.1 Visual Studio 2013 (Windows Phone Store 앱이 아닌 Windows Phone 앱)을 만들고 있습니다. 나는 거의 나의 응용을 끝냈다. 그러나 결국 결과를 자르려고 할 때 직사각형의 적절한 지점을 보낼 수 없어 이미지 위에 그려졌습니다.Windows Phone 8.1의 자르기 이미지에 문제가 있습니다.

private void btnCrop_Click(object sender, EventArgs e){ 
      // Get the size of the source image captured by the camera 
      double originalImageWidth = wbPanoramica.PixelWidth; 
      double originalImageHeight = wbPanoramica.PixelHeight; 

      // Get the size of the image when it is displayed on the phone 
      double displayedWidth = VisorPicture.ActualWidth; 
      double displayedHeight = VisorPicture.ActualHeight; 

      // Calculate the ratio of the original image to the displayed image 
      double widthRatio = originalImageWidth/displayedWidth; 
      double heightRatio = originalImageHeight/displayedHeight; 

      // Calculate the offset of the cropped image. This is the distance, in pixels, to the top left corner 
      // of the cropping rectangle, multiplied by the image size ratio. 
      int xoffset = (int)(((p1.X < p2.X) ? p1.X : p2.X) * widthRatio); 
      int yoffset = (int)(((p1.Y < p2.Y) ? p1.Y : p2.X) * heightRatio); 
      int X1 = (int)(p1.X * widthRatio); 
      int Y1 = (int)(p1.Y * heightRatio); 



      var cropped = wbPanoramica.Crop(X1, Y1, yoffset, xoffset); 

      wbPanoramica = cropped; 
      // Set the source of the image control to the new cropped bitmap 
      VisorPicture.Source = wbPanoramica; 
      rect.Visibility = Visibility.Collapsed; 


      //Enable accept and reject buttons to save or discard current cropped image. 
      //Disable crop button until a new cropping region is selected. 
      btnAceptar.IsEnabled = true; 
      btnReject.IsEnabled = true; 
      btnCortar.IsEnabled = false; 

      //Instructional text 
      textStatus.Text = "Continue editando la imagen, acepte, o rechace el cambio"; 
     } 

답변

0

문제가 발생했습니다. 마치 자르기를하는 동안 정확한 픽셀을 얻지 못하는 것 같은가요? 나는 비슷한 문제가 있었다. 이

을하는 데 도움이 알려줘, 작물 픽셀을 통과하는이

var cropped = wbPanoramica.Crop(X1*2, Y1*2, yoffset, xoffset); 

처럼 통과하는 동안 내가 한 일은

wbPanoramica.Height=wbPanoramica.Height/2; 
wbPanoramica.Width=wbPanoramica.Width/2; 

이었다

관련 문제