public static Bitmap Pixelate(Bitmap image, int blurSize) { return(ImageProcessor.Pixelate(image, new Rectangle(0, 0, image.Width, image.Height), blurSize)); }
private void HandleImage(ListViewItem item, string dir, int effect, int strength) { Image <Bgr, byte> image1 = new Image <Bgr, byte>(item.SubItems[1].Text); List <Rectangle> list = FaceDetection.Detect(image1, "haarcascade_frontalface_default.xml"); this.bkgdWorker.ReportProgress(list.Count, (object)item); Bitmap image2 = image1.ToBitmap(); if (effect != 2) { bool usePixelate = (effect == 1) ? true : false; foreach (Rectangle rectangle in list) { image2 = usePixelate ? ImageProcessor.Pixelate(image2, rectangle, strength) : ImageProcessor.Blur(image2, rectangle, strength); } } string text = item.SubItems[0].Text; string str1 = ".png"; string str2 = dir + "\\" + text.Substring(0, text.LastIndexOf(".")); bool flag = true; int num = 0; string str3 = ""; while (flag) { if (File.Exists(str2 + str3 + str1)) { ++num; str3 = "(" + num.ToString() + ")"; } else { flag = false; } } image2.Save(str2 + str3 + str1); image2.Dispose(); image1.Dispose(); this.bkgdWorker.ReportProgress(-1, (object)item); }