2016-05-13 45 views
0

我使用的應用程序的Windows 10.我試圖讓圖像編輯應用程序。如何在Windows 10移動應用程序中使用LumiaImagingSDK.UWP 3.0?

var client = new HttpClient(); 
var stream = await client.GetStreamAsync(ImageUrl); 
var source = new StreamImageSource(stream); 
var info = await source.GetInfoAsync(); 

,我得到的線var source = new StreamImageSource(stream);一個錯誤:

Exception thrown: 'System.IO.FileNotFoundException' in Lumia.Imaging.Managed.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.ni.dll

RenderImage error: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

我在做什麼錯? 我使用LumiaImagingSDK.UWP 3.0。

+0

我無法重現您的問題,請您提供更多詳細信息?我想你是通過互聯網上的url獲得圖片,那麼你想要做什麼? –

+0

是的。我從互聯網上的URL獲取圖像。 – arsenium

+0

然後你想用ImageingSDK對這個圖像做什麼? –

回答

0

由成像SDK的StreamImageSource構造函數支持的格式爲: 的Jpeg 巴 的Gif 骨形態發生蛋白 WBMP 的Tiff

檢查您的網址是否正確,並指出這些圖像格式之一。

+0

我在我的問題中缺少sdk版本。我使用LumiaImagingSDK.UWP 3.0。在v2.0工作正常。如何使用LumiaImagingSDK.UWP 3.0和來自url的圖像一起工作?我使用Jpeg格式。 – arsenium

0

正如我們在評論已經討論過,要模糊圖像,並有內置BlurEffect Class在LumiaImagingSDK.UWP 3.0,我用這個效果寫到這裏演示:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="500" /> 
     <RowDefinition Height="50" /> 
    </Grid.RowDefinitions> 
    <Grid Grid.Row="0"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="*" /> 
     </Grid.ColumnDefinitions> 
     <Image x:Name="originalimg" Grid.Column="0" /> 
     <SwapChainPanel x:Name="SwapChainPanelTarget" Grid.Column="1" /> 
    </Grid> 
    <Button Content="Click Me" Click="Button_Click" Grid.Row="1" HorizontalAlignment="Center" /> 
</Grid> 

後面的代碼:

private async void Button_Click(object sender, RoutedEventArgs e) 
{ 
    Uri uri = new Uri("xxxx(uri address)"); 
    using (HttpClient client = new HttpClient()) 
    { 
     try 
     { 
      HttpResponseMessage response = await client.GetAsync(uri); 
      if (response != null && response.StatusCode == HttpStatusCode.Ok) 
      { 
       string filename = "test.jpg"; 
       var imageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); 
       using (IRandomAccessStream stream = await imageFile.OpenAsync(FileAccessMode.ReadWrite)) 
       { 
        await response.Content.WriteToStreamAsync(stream); 
       } 
       StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(filename); 

       //show original image in the Image control 
       IRandomAccessStream inputStream1 = await file.OpenReadAsync(); 
       BitmapImage bitmap = new BitmapImage(); 
       bitmap.SetSource(inputStream1); 
       originalimg.Source = bitmap; 

       //use the blureffect 
       IRandomAccessStream inputStream = await file.OpenReadAsync(); 
       BlurEffect blureffect = new BlurEffect(); 
       inputStream.Seek(0); 
       blureffect.Source = new Lumia.Imaging.RandomAccessStreamImageSource(inputStream); 
       var render = new SwapChainPanelRenderer(blureffect, SwapChainPanelTarget); 
       await render.RenderAsync(); 
      } 
     } 
     catch 
     { 
     } 
    } 
} 

我存儲在圖像中的本地文件夾,每次,我用Windows.Web.Http namespace,不System.Net.Http Namespace。由於我無法重現您的問題,因此將圖像保存到文件並在此讀取文件流即可。

相關問題