public void ConvertColors(Color original, Color expectedGrey) { // arrange // act var grey = _greyScaleConvertor.ToGreyscale(original); // assert Assert.AreEqual(expectedGrey, grey); }
public Tile GetTile( Bitmap source, int tileRowIndex, int tileColIndex, int tileWidth, int tileHeight, Color defaultBackgroundColour) { var tile = new Color[tileHeight, tileWidth]; var offsetStartY = tileRowIndex * tileWidth; var offsetStartX = tileColIndex * tileHeight; // vertical for (var rowIndex = 0; rowIndex < tileHeight; rowIndex++) { // horizontal for (var colIndex = 0; colIndex < tileWidth; colIndex++) { var pixelX = offsetStartX + colIndex; var pixelY = offsetStartY + rowIndex; if (pixelX < source.Width && pixelY < source.Height) { var sourceColor = source.GetPixel(pixelX, pixelY); var greyscale = _colorConvertor.ToGreyscale(sourceColor); tile[rowIndex, colIndex] = greyscale; } else { tile[rowIndex, colIndex] = defaultBackgroundColour; } } } return(new Tile() { Data = tile }); }