Ejemplo n.º 1
0
        public void Test_Resolution_SetResolution()
        {
            Resolution resolution = new Resolution(10, 5);
            resolution.SetResolution(4, 2);

            Assert.AreEqual(resolution.Width, 4);
            Assert.AreEqual(resolution.Height, 2);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public void Test_Canvas_GetResolution()
        {
            Canvas canvas = new Canvas(8, 6);

            Resolution expectedResolution = new Resolution(8, 6);

            Assert.AreEqual(expectedResolution.Width, canvas.GetResolution().Width);
            Assert.AreEqual(expectedResolution.Height, canvas.GetResolution().Height);
        }