private static Bitmap WildBoardHelepr(Bitmap img, int n, WildBoardVariant variant) { Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb); if (Checks.RGBinput(img)) { var ColorList = Helpers.GetPixels(img); int[,] resultR = new int[img.Height, img.Width]; int[,] resultG = new int[img.Height, img.Width]; int[,] resultB = new int[img.Height, img.Width]; int Boardrows = (int)Math.Ceiling((double)img.Height / n); int Boardcols = (int)Math.Ceiling((double)img.Width / n); var board = CheckerBoardHelper(n, Boardrows, Boardcols); var gray = Helpers.RGBToGrayArray(img); for (int i = 0; i < img.Height; i++) { for (int j = 0; j < img.Width; j++) { if (variant == WildBoardVariant.Variant1) { if (board[i, j] == 0) { resultR[i, j] = ColorList[0].Color[i, j]; resultG[i, j] = ColorList[1].Color[i, j]; resultB[i, j] = ColorList[2].Color[i, j]; } else { resultR[i, j] = gray[i, j]; resultG[i, j] = gray[i, j]; resultB[i, j] = gray[i, j]; } } else { if (board[i, j] == 255) { resultR[i, j] = ColorList[0].Color[i, j]; resultG[i, j] = ColorList[1].Color[i, j]; resultB[i, j] = ColorList[2].Color[i, j]; } else { resultR[i, j] = gray[i, j]; resultG[i, j] = gray[i, j]; resultB[i, j] = gray[i, j]; } } } } image = Helpers.SetPixels(image, resultR, resultG, resultB); } return(image); }
//creater CheckerBoard on RGB image alternating gray and color cells //n - pixels per cell public static void WildBoard(Bitmap img, int n, WildBoardVariant variant) { string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension); string imgName = GetImageInfo.Imginfo(Imageinfo.FileName); string defPath = GetImageInfo.MyPath("Rand"); Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb); image = WildBoardHelepr(img, n, variant); string outName = defPath + imgName + "_CheckerBoard" + imgExtension; Helpers.SaveOptions(image, outName, imgExtension); }
public static Bitmap WildBoardBitmap(Bitmap img, int n, WildBoardVariant variant) { return(WildBoardHelepr(img, n, variant)); }