Exemplo n.º 1
0
        public void WriteImage(SDK.ExportContext stream, IMAGE32 image, IMAGEENCODER encoder)
        {
            if (image == null)
            {
                return;
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (encoder == null)
            {
                throw new ArgumentNullException(nameof(encoder));
            }

            if (PostProcessing != null)
            {
                foreach (var xform in PostProcessing)
                {
                    image.Mutate(dc => xform(dc));
                }
            }

            encoder?.Invoke(stream, image);
        }
Exemplo n.º 2
0
        protected override IMAGE32 Evaluate()
        {
            var size = new SixLabors.Primitives.Size(Width, Height);

            var result = new IMAGE32(size.Width, size.Height);

            using (var target = new IMAGE32(size.Width, size.Height))
            {
                var substrate = Epsylon.ImageSharp.Procedural.Processing.Substrate.Create(target, RandomSeed.GetRandomSeedHash(), Palette);

                for (int i = 0; i < Iterations; ++i)
                {
                    this.SetProgressPercent(i * 100 / Iterations);

                    substrate.DrawStep();
                }

                result.Mutate
                (
                    dc =>
                {
                    dc.Fill(Rgba32.White);
                    dc.DrawImage(target, 1);
                }
                );

                return(result);
            }
        }
Exemplo n.º 3
0
        protected override IMAGE32 Evaluate()
        {
            var img = new IMAGE32(this.Width, this.Height);

            img.Mutate(dc => dc.BackgroundColor(new PIXEL32(Color)));

            return(img);
        }
Exemplo n.º 4
0
        protected override IMAGE32 Evaluate()
        {
            var img = new IMAGE32(this.Width, this.Height);

            img.Mutate(dc => dc.FillCheckers(this.CellWidth, this.CellHeight, new PIXEL32(OddColor), new PIXEL32(EvenColor)));

            return(img);
        }
Exemplo n.º 5
0
        public static Object CreatePreview(this IMAGE32 image, UberFactory.SDK.PreviewContext context)
        {
            if (image == null)
            {
                return(null);
            }

            if (true)
            {
                var sinfo = image.GetSubjectInfo();

                if (sinfo != null)
                {
                    var l0 = sinfo.Center + new Size(3, 0);
                    var l1 = sinfo.Center + new Size(3, 0);
                    image.Mutate(dc => dc.DrawLines(COLOR.Red, 1, l0, l1));

                    l0 = sinfo.Center + new Size(0, 3);
                    l1 = sinfo.Center - new Size(0, 3);
                    image.Mutate(dc => dc.DrawLines(COLOR.Red, 1, l0, l1));

                    if (sinfo.Size.HasValue)
                    {
                        image.Mutate(dc => dc.DrawPolygon(COLOR.Red, 1, sinfo.BoundsFloat.Get4Points()));
                    }
                }
            }

            var date = DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
            var time = DateTime.Now.ToString("hhmmss", System.Globalization.CultureInfo.InvariantCulture);

            var files = context.CreateMemoryFile($"preview-{date}-{time}.png");

            files.WriteStream(s => image.SaveAsPng(s));

            image.Dispose();

            return(files);
        }
Exemplo n.º 6
0
        public static IMAGE32 RenderText(this SixLabors.Fonts.FontFamily ffamily, string text, float fsize, float padding, COLOR color, TextGraphicsOptions options)
        {
            // http://sixlabors.com/2017/04/08/watermarks/

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var font     = new SixLabors.Fonts.Font(ffamily, fsize);
            var roptions = new SixLabors.Fonts.RendererOptions(font, 96);
            var size     = SixLabors.Fonts.TextMeasurer.Measure(text, roptions);

            var w   = (int)Math.Ceiling(size.Width + padding * 2);
            var h   = (int)Math.Ceiling(size.Height + padding * 2);
            var img = new IMAGE32(w, h);

            img.Mutate(dc => dc.DrawText(options, text, font, color, new System.Numerics.Vector2(padding, padding)));

            return(img);
        }