Reputation: 571
I work with app for windows 10. I tried to make an application for image editing.
var client = new HttpClient();
var stream = await client.GetStreamAsync(ImageUrl);
var source = new StreamImageSource(stream);
var info = await source.GetInfoAsync();
and I get an error in line 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)
What am I doing wrong? I Work with LumiaImagingSDK.UWP 3.0.
Upvotes: 0
Views: 183
Reputation: 16652
As we've discussed in the comment, you want to blur image, and there is built-in BlurEffect Class in the LumiaImagingSDK.UWP 3.0, I used this effect to wrote a demo here:
<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>
Code behind:
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
{
}
}
}
I stored the image each time in the local folder, and I used Windows.Web.Http namespace, not System.Net.Http Namespace. Since I can't reproduce your problem, to save the image to file and read the file stream here can work.
Upvotes: 0
Reputation: 715
The formats supported by the StreamImageSource ctor of the Imaging SDK are : Jpeg Png Gif Bmp Wbmp Tiff
Check that your URL is correct and points to one of these images formats.
Upvotes: 0