BlurredBackgroundPoc.BlurredImage.CreateBlurredImage C# (CSharp) Method

CreateBlurredImage() private method

private CreateBlurredImage ( ImageSource imageSource ) : void
imageSource ImageSource
return void
        private void CreateBlurredImage(ImageSource imageSource)
        {
            if (BlurredStrengh % 2 == 0 && BlurredStrengh != 0)
                throw new ArgumentException();

            if (ImageSource == null || _blurredImage == null) 
                return;

            var bitmapImage = ((BitmapSource)imageSource);
            if (bitmapImage.PixelHeight == 0)
                return;

            WriteableBitmap writeableBmp = new WriteableBitmap(bitmapImage);
            if (BlurredStrengh > 0)
                writeableBmp.BoxBlur(BlurredStrengh);

            _blurredImage.Source = writeableBmp;

            SetOverlaySize();
            _rootGrid.Opacity = 1;
        }