/// <summary> /// convolves the _scale matrix with _bitmap /// INVOKE IN "USING" /// </summary> /// <returns>the result of the convolution</returns> private Bitmap convolveBitmap() { Bitmap toReturn = new Bitmap(_bitmap); using (Bitmap copy = new Bitmap(_bitmap)) { foreach (int x in Enumerable.Range(0, _bitmap.Width - 1)) { foreach (int y in Enumerable.Range(0, _bitmap.Height - 1)) { BigColor accum = new BigColor(); if (x > 0 && y > 0) { accum += new BigColor(copy.GetPixel(x - 1, y - 1)) * _scale[0, 0]; accum += new BigColor(copy.GetPixel(x, y - 1)) * _scale[1, 0]; accum += new BigColor(copy.GetPixel(x + 1, y - 1)) * _scale[2, 0]; accum += new BigColor(copy.GetPixel(x - 1, y)) * _scale[0, 1]; accum += new BigColor(copy.GetPixel(x, y)) * _scale[1, 1]; accum += new BigColor(copy.GetPixel(x + 1, y)) * _scale[2, 1]; accum += new BigColor(copy.GetPixel(x - 1, y + 1)) * _scale[0, 2]; accum += new BigColor(copy.GetPixel(x, y + 1)) * _scale[1, 2]; accum += new BigColor(copy.GetPixel(x + 1, y + 1)) * _scale[2, 2]; toReturn.SetPixel(x, y, accum.toColor()); } } } } return(toReturn); }
public BigBitmap(Bitmap from) { _width = from.Width; _height = from.Height; data = new BigColor[_width, _height]; foreach (int x in Enumerable.Range(0, _width - 1)) { foreach (int y in Enumerable.Range(0, _height - 1)) { data[x, y] = new BigColor(from.GetPixel(x, y)); } } }