![](/img/trans.png)
[英]FolderPicker does not work in UWP Windows 10 app (mobile)
[英]How to work with LumiaImagingSDK.UWP 3.0 in windows 10 mobile app?
我使用適用於Windows 10的應用程序。我試圖制作一個用於圖像編輯的應用程序。
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);
行中收到錯誤 :
引發異常:Lumia.Imaging.Managed.dll中的“ System.IO.FileNotFoundException”
引發異常:mscorlib.ni.dll中的“ System.IO.FileNotFoundException”
RenderImage錯誤:找不到指定的模塊。 (來自HRESULT的異常:0x8007007E)
我究竟做錯了什么? 我使用LumiaImagingSDK.UWP 3.0。
Imaging SDK的StreamImageSource ctor支持的格式為:Jpeg Png Gif Bmp Wbmp Tiff
檢查您的URL是否正確,並指向這些圖像格式之一。
正如我們在評論中討論的那樣,您想模糊圖像,並且LumiaImagingSDK.UWP 3.0中有內置的BlurEffect類 ,我使用這種效果在此處編寫了一個演示:
<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命名空間 ,而不是System.Net.Http命名空間 。 由於無法解決您的問題,因此可以將圖像保存到文件並在此處讀取文件流。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.