public Bitmap GetEmbroidery(Bitmap image, Settings settings) { if (settings.CellsCount <= 0) throw new WrongInitializedException("cellsCount has to be > 0"); if (settings.Coefficient <= 0) throw new WrongInitializedException("coefficient has to be > 0"); if (settings.Palette == null || settings.Palette.Count == 0) throw new WrongInitializedException("palette has to be initialized"); Canvas imageCanvas = CanvasConverter.ConvertBitmapToCanvas(image); log.WriteEntry("---------Time spent----------"); log.WriteEntry(@"-----Convert Bitmap To Canvas: " + Environment.NewLine + "---------resol: " + image.Width.ToString() + "x" + image.Height.ToString()); Canvas pattern = PatternMapGenerator.Generate(imageCanvas, settings); log.WriteEntry(@"-----Generate pattern: "+ Environment.NewLine + "--------resol: " + imageCanvas.Width.ToString() + "x" + imageCanvas.Height.ToString() + Environment.NewLine + "--------cells: " + settings.CellsCount.ToString()); Resolution resolution = new Resolution(pattern.Width * settings.Coefficient, pattern.Height * settings.Coefficient); Canvas result = new Canvas(resolution); settings.Decorate(result, pattern); Bitmap resultImage = CanvasConverter.ConvertCanvasToBitmap(result); log.WriteEntry(@"-----Convert Canvas To Bitmap: " + Environment.NewLine + "---------resol: " + result.Width.ToString() + "x" + result.Height.ToString()); log.WriteEntry("---------End time spent-------"); return resultImage; }
public void Test_Settings_Decorate() { Settings settings = new Settings(); var mock = new Mock<IDecoratorsComposition>(); mock.Setup(dec => dec.Decorate(It.IsAny<Canvas>(), It.IsAny<Canvas>(), settings)); settings.DecoratorsComposition = mock.Object; settings.Decorate(new Canvas(1, 1), new Canvas(2, 2)); mock.Verify(d => d.Decorate(It.IsAny<Canvas>(), It.IsAny<Canvas>(), settings)); }