Reputation: 5929
I've been trying to apply a filter from Nokias Imaging SDK to a WriteableBitmap. So far, I didn't have any success. The "best" I got is the following, which crashes on renderer.RenderAsync()
MemoryStream stream = new MemoryStream(App.MainViewModel.Current.Album.Cover.ToByteArray());
StreamImageSource streamImage = new StreamImageSource(stream);
FilterEffect filters = new FilterEffect(streamImage);
WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(filters);
BlurFilter blurFilter = new BlurFilter();
filters.Filters = new[] { blurFilter };
var result = await renderer.RenderAsync();
The ToByteArray()
extension method on Cover (which is a WriteableBitmap
), is provided by the WriteableBitmapEx library.
Has anyone had the same problem?
Upvotes: 0
Views: 306
Reputation: 17607
You are getting an exception in renderer.RenderAsync() because you aren't setting a WriteableBitmap property of WriteableBitmapRenderer.
The WriteableBitmapRenderer can not create a WriteableBitmap for you, as it needs to be created on the UI thread. So you must create it yourself and pass it into the renderer object (either in a constructor or by setting the property).
Upvotes: 1