2014-04-12 50 views

回答

1

這是來自諾基亞API參考文檔的摘錄,其可以在這裏找到:

http://developer.nokia.com/resources/library/Imaging_API_Ref/nokiagraphicsimaging-namespace/cropfilter-class.html

該樣品需要CameraCaptureTask結果照片並施加[作物]濾鏡。

async void CaptureTask_Completed(object sender, PhotoResult e) 
{ 
    // Create a source to read the image from PhotoResult stream 
    using (var source = new StreamImageSource(e.ChosenPhoto)) 
    { 
     // Create effect collection with the source stream 
     using (var filters = new FilterEffect(source)) 
     { 
      // Initialize the filter 
      var sampleFilter = new CropFilter(new Windows.Foundation.Rect(0, 0, 500, 500)); 

      // Add the filter to the FilterEffect collection 
      filters.Filters = new IFilter[] { sampleFilter }; 

      // Create a target where the filtered image will be rendered to 
      var target = new WriteableBitmap((int)ImageControl.ActualWidth, (int)ImageControl.ActualHeight); 

      // Create a new renderer which outputs WriteableBitmaps 
      using (var renderer = new WriteableBitmapRenderer(filters, target)) 
      { 
       // Render the image with the filter(s) 
       await renderer.RenderAsync(); 

       // Set the output image to Image control as a source 
       ImageControl.Source = target; 
      } 
     } 
    } 
}