/// <summary> /// Creates a new filtered WriteableBitmap. /// </summary> /// <param name="bmp">The WriteableBitmap.</param> /// <param name="kernel">The kernel used for convolution.</param> /// <returns>A new WriteableBitmap that is a filtered version of the input.</returns> public static WriteableBitmap Convolute(this WriteableBitmap bmp, int[,] kernel) { var kernelFactorSum = 0; foreach (var b in kernel) { kernelFactorSum += b; } return(bmp.Convolute(kernel, kernelFactorSum, 0)); }
private void GalleryDetailViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "Item") { log.Info("Changing gallery detail source"); _source = ImageSourceFromFile(_model.MediaPath, MAX_WIDTH_IMAGE, MAX_WIDTH_BLUR); //blur a lot //TODO try other kernels WriteableBitmap blur = new WriteableBitmap(ImageSourceFromFile(_model.MediaPath, MAX_WIDTH_BLUR, MAX_HEIGHT_BLUR)); for (int i = 0; i < 10; i++ ) blur = blur.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5); _blurSource = blur; RaisePropertyChanged("Title"); RaisePropertyChanged("ImageSource"); RaisePropertyChanged("BlurSource"); RaisePropertyChanged("Description"); RaisePropertyChanged("PageLeftButtonVisibility"); RaisePropertyChanged("PageRightButtonVisibility"); } }