public void GaussianBlur() { using (Bitmap TestObject = new Bitmap(@"..\..\Data\Image\Lenna.jpg")) { using (Bitmap Image = Assert.Do<Bitmap>(() => TestObject.GaussianBlur(3, @".\Testing\LennaGaussianBlur.jpg"))) { Assert.NotNull(Image); } } }
private Bitmap MergingAllImage() { Bitmap LastBitmap = new Bitmap(this.bitmap.Width, this.bitmap.Height); using (Graphics grp = Graphics.FromImage(LastBitmap)) { var DefaultBackgroundBrushes = Brushes.Black; if (App.Default.IsBlackShadow) { DefaultBackgroundBrushes = Brushes.White; } grp.FillRectangle( DefaultBackgroundBrushes, 0, 0, this.bitmap.Width, this.bitmap.Height); } Rectangle _Rectangle = new Rectangle(0, 0, LastBitmap.Width, LastBitmap.Height); Queue TempQueue = new Queue(); LastBitmap.GaussianBlur(ref _Rectangle, App.Default.ShadowBlurRadio); if(ImgQueue.Count > 0) { var canvas = Graphics.FromImage(LastBitmap); while(ImgQueue.Count > 0) { Bitmap tmpImg=(Bitmap)ImgQueue.Dequeue(); if (App.Default.IsBlackShadow) { tmpImg.MakeTransparent(Color.White); } else { tmpImg.MakeTransparent(Color.Black); } tmpImg.GaussianBlur(ref _Rectangle,App.Default.ShadowBlurRadio); if (ImgQueue.Count < ImgQueueLitmitation) { TempQueue.Enqueue(tmpImg); } ColorMatrix cm = new ColorMatrix(); cm.Matrix33 = App.Default.ShadowAlpha; ImageAttributes _ImageAttributes = new ImageAttributes(); _ImageAttributes.SetColorMatrix(cm); canvas.InterpolationMode = InterpolationMode.HighQualityBicubic; canvas.DrawImage(tmpImg, new Rectangle(0, 0, this.panelView.Size.Width, this.panelView.Size.Height), 0, 0, this.panelView.Size.Width, this.panelView.Size.Height,GraphicsUnit.Pixel,_ImageAttributes); canvas.Save(); } ImgQueue = TempQueue; ImgQueue.TrimToSize(); } return LastBitmap; }