public void Convert(List <TextPage> pages, IMyImage image) { _pages = pages; _image = image; foreach (var textPage in _pages) { var t = new Coord { X = textPage.X, Width = _image.GetHeight() - textPage.Height, Y = textPage.Y - textPage.X, Height = textPage.Height - textPage.Width }; textPage.X = t.X; textPage.Width = t.Width; textPage.Y = t.Y; textPage.Height = t.Height; foreach (var textParagraph in textPage.Paragraphs) { var t1 = new Coord { X = textParagraph.X, Width = _image.GetHeight() - textParagraph.Height, Y = textParagraph.Y - textParagraph.X, Height = textParagraph.Height - textParagraph.Width }; } } }
private void ChangeToGrayscale(IMyImage source, IMyImage dist, int x1, int y1, int x2, int y2) { for (int i = x1; i < x2; i++) { for (int j = y1; j < y2; j++) { int newcolor = (int)(0.299 * source[i, j].R + 0.587 * source[i, j].G + 0.114 * source[i, j].B); dist[i, j] = Color.FromArgb(newcolor, newcolor, newcolor); } } }
private static double[] GetSumRgb(IMyImage source, int x1, int y1, int x2, int y2) { var res = new double[3]; for (var i = x1; i < x2; i++) { for (var j = y1; j < y2; j++) { var color = source[i, j]; res[0] += color.R; res[1] += color.B; res[2] += color.G; } } return(res); }