public byte[] Calc(FileInfo file) { if (CheckData.IsObjectNull(file) || !file.Exists) { return(new byte[] { }); } using (Bitmap bitmap = new Bitmap(file.FullName)) { if ((this.max_width != 0 && bitmap.Width > this.max_width) || (this.max_height != 0 && bitmap.Height > this.max_height)) { Size new_size = ResizeImage(bitmap.Width, bitmap.Height, max_width, max_height); using (Bitmap smallbitmap = new Bitmap(bitmap, new_size)) { int x = RandomData.GetInt(0, bitmap.Width); int y = RandomData.GetInt(0, bitmap.Height); Color nc = RandomData.ColorRGB(); bitmap.SetPixel(x, y, nc); } } else { int x = RandomData.GetInt(0, bitmap.Width); int y = RandomData.GetInt(0, bitmap.Height); Color nc = RandomData.ColorRGB(); bitmap.SetPixel(x, y, nc); } byte[] bytes = new byte[] { }; for (int rate = 100; rate > 1; rate -= 5) { bytes = CreateNewImg(file, rate); if (!IsBigImg(bytes.Length)) { break; } } return(bytes); } }