Пример #1
0
        public static Bitmap GetTileableRectangularPattern(Bitmap template, MirrorSystem mirrorSystem)
        {
            Bitmap bitmap = new Bitmap(
                template.Width * mirrorSystem.TilableRectangularPatternHorizontalSpan,
                template.Height * mirrorSystem.TilableRectangularPatternVerticalSpan);
            //bitmap.SetResolution(template.HorizontalResolution, template.VerticalResolution);

            var flippedXTemplate = template.Clone() as Bitmap;

            flippedXTemplate.RotateFlip(RotateFlipType.RotateNoneFlipX);

            Bitmap[] templates = { template, flippedXTemplate };

            var g = Graphics.FromImage(bitmap);

            g.InterpolationMode = InterpolationMode;
            g.SmoothingMode     = SmoothingMode;
            g.PixelOffsetMode   = PixelOffsetMode;

            g.DrawSet(templates, mirrorSystem.TransformationSetForTilableRectangularPattern);

            GraphicsExtensions.FillGaps(bitmap);

            return(bitmap);
        }
Пример #2
0
        public static Bitmap ExtractTemplate(Bitmap image, MirrorSystem mirrorSystem,
                                             int size, int x, int y, float angle)
        {
            var pSize = mirrorSystem.GetUntransformedTemplateRectangularSize(size);

            Bitmap template = new Bitmap((int)Math.Round(pSize.X), (int)Math.Round(pSize.Y, 0));
            //template.SetResolution(image.HorizontalResolution, image.VerticalResolution);
            var gTemplate = Graphics.FromImage(template);

            gTemplate.SmoothingMode     = SmoothingMode;
            gTemplate.PixelOffsetMode   = PixelOffsetMode;
            gTemplate.InterpolationMode = InterpolationMode;

            gTemplate.Clip = new Region(
                mirrorSystem.GetUntransformedTemplateClippingPolygon(size).ToGraphicsPath());

            gTemplate.RotateTransform(-angle);
            gTemplate.TranslateTransform(-x, -y);
            gTemplate.DrawImage(image, new PointF(0, 0));
            gTemplate.Dispose();

            return(template);
        }
Пример #3
0
 public void SetMirorrSystem(MirrorSystem mirrorSystem)
 {
     model.MirrorSystem = mirrorSystem;
     view.UpdateMirrorSystem();
 }