Example #1
0
        public void AdjustmentLayerWithSpecifiedLayerStyleHasSpecifiedLayerStyleWhenCreatedWithLambda()
        {
            var layer = new AdjustmentLayer(LayerStyle.Add(0.6), context => CreateTestEffect(context));

            Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
            Assert.AreEqual(0.6, layer.Style.Opacity);
        }
Example #2
0
        public PopEffect()
        {
            var globalCurve = new Curve(CurveInterpolation.NaturalCubicSpline)
            {
                Points = new[]
                {
                    new Point(0, 0),
                    new Point(68, 60),
                    new Point(144, 163),
                    new Point(255, 255),
                }
            };

            var overlayFactory = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Pop3.png",
                "ms-appx:///images/Filters_Portrait_Overlay_Pop3.png",
                "ms-appx:///images/Filters_Square_Overlay_Pop3.png");

            LayerList = new LayerList()
            {
                new AdjustmentLayer(LayerStyle.Normal(), new ContrastEffect(1.0)),
                new AdjustmentLayer(LayerStyle.Normal(), new CurvesEffect(globalCurve)),
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect(0.54, 0.64, 0.0, -0.1)),
                new AdjustmentLayer(LayerStyle.Normal(), new LevelsEffect(0.7, 0.7 / 2, 0)),
                new Layer(LayerStyle.Screen(1.0), context => new ColorImageSource(context.HintedRenderSize, Color.FromArgb(255, 108, 0, 148))),
                new Layer(LayerStyle.Lighten(), context => overlayFactory.CreateAsync(context.HintedRenderSize))
            };
        }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                string     response = string.Empty;
                Workspace  wpk      = new Workspace();
                DataStore  store    = new DataStore();
                Layer      layer    = new Layer();
                LayerStyle style    = new LayerStyle();

                var watch = System.Diagnostics.Stopwatch.StartNew();

                //response = wpk.Add("GeoTest");
                //response = store.AddStoreFromDb("GeoTest", "geoDb", "ACC1");
                //response = layer.AddLayerFromDb("GeoTest", "geoDb", "hitbgt", "hitbgt", "polygon");

                response = wpk.GetNamespaceUri("MT12");

                Console.WriteLine(response);

                watch.Stop();
                var time = watch.ElapsedMilliseconds / 1000;
                Console.WriteLine(Convert.ToString(time));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }

            Console.ReadKey();
        }
Example #4
0
        public NeonEffect()
        {
            var saturationLightnessEffect = new SaturationLightnessEffect(null, new Curve(CurveInterpolation.Linear, new[]
            {
                new Point(0, 36),
                new Point(45, 60),
                new Point(104, 146),
                new Point(197, 207),
                new Point(255, 245)
            }));


            var hslEffect = new HueSaturationLightnessEffect
            {
                SaturationCurve = PhotoshopAlike.CreateCurveFromHueRangeAdjustments(
                    new PhotoshopAlike.HueRangeAdjustment(0, 60),
                    new PhotoshopAlike.HueRangeAdjustment(1, -5),
                    new PhotoshopAlike.HueRangeAdjustment(2, -7),
                    new PhotoshopAlike.HueRangeAdjustment(3, -10),
                    new PhotoshopAlike.HueRangeAdjustment(5, 25),
                    new PhotoshopAlike.HueRangeAdjustment(6, 22))
            };


            LayerList.AddRange(
                new AdjustmentLayer(LayerStyle.Normal(), saturationLightnessEffect),
                new AdjustmentLayer(LayerStyle.Normal(), Lookups.NeonCurvesEffect),
                new AdjustmentLayer(LayerStyle.Normal(), hslEffect),
                new AdjustmentLayer(LayerStyle.Normal(), context => new CachingEffect()),
                new AdjustmentLayer(LayerStyle.Softlight(0.75), context => new SDKTestApp_Native.HighpassEffect(32, false, 8))
                );
        }
Example #5
0
        public void AdjustmentLayerWithSpecifiedLayerStyleHasSpecifiedLayerStyleWhenCreatedWithAsynchronousImageProvider()
        {
            var layer = new AdjustmentLayer(LayerStyle.Add(0.6), CreateTestEffectAsync());

            Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
            Assert.AreEqual(0.6, layer.Style.Opacity);
        }
Example #6
0
        public OldPosterEffect()
        {
            // Curves
            var globalCurve = new Curve(CurveInterpolation.NaturalCubicSpline)
            {
                Points = new[]
                {
                    new Point(0, 0),
                    new Point(38, 17),
                    new Point(160, 210),
                    new Point(231, 250),
                    new Point(255, 255)
                }
            };

            var overlayFactory = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Poster2.png",
                "ms-appx:///images/Filters_Portrait_Overlay_Poster2.png",
                "ms-appx:///images/Filters_Square_Overlay_Poster2.png");

            LayerList = new LayerList(
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect(0.54, 0.64, 0.0, -0.1)),
                new AdjustmentLayer(LayerStyle.Normal(), new CurvesEffect(globalCurve)),
                new Layer(LayerStyle.Multiply(), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 255, 167, 151))),
                new Layer(LayerStyle.Normal(), context => overlayFactory.CreateAsync(context.BackgroundLayer.ImageSize))
                );
        }
        public async Task ImageProviderTopology()
        {
            var backgroundImage = new ColorImageSource(new Size(100, 100), Color.FromArgb(255, 128, 128, 128));
            var layerList       = new LayerList(backgroundImage, backgroundImage.ImageSize, new Layer[]
            {
                new Layer(LayerStyle.Multiply(), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 32, 16, 8))),
                new AdjustmentLayer(LayerStyle.Screen(0.5), new ContrastEffect(0.7)),
                new AdjustmentLayer(LayerStyle.Normal(), new BrightnessEffect(0.7)),
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect())
            });

            var layersEffect = await layerList.ToImageProvider(new Size(50, 50)).AsTask();

            var chain = GetChain(layersEffect);


            Assert.AreEqual(5, chain.Count);

            Assert.AreSame(backgroundImage, chain.FirstOrDefault());

            Assert.IsInstanceOfType(chain[1], typeof(BlendEffect)); // Layer with ColorImageSource
            Assert.IsInstanceOfType(((BlendEffect)chain[1]).ForegroundSource, typeof(ColorImageSource));

            Assert.IsInstanceOfType(chain[2], typeof(BlendEffect));
            Assert.IsInstanceOfType(((BlendEffect)chain[2]).ForegroundSource, typeof(ContrastEffect));

            Assert.IsInstanceOfType(chain[3], typeof(BrightnessEffect));
            Assert.IsInstanceOfType(chain[4], typeof(GrayscaleEffect));
        }
        public void LayerWithSpecifiedLayerStyleHasSpecifiedLayerStyleWhenCreatedWithLambdaReturningAsynchronousImageProvider()
        {
            var layer = new Layer(LayerStyle.Add(0.6), context => CreateTestImageProviderAsync(context));

            Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
            Assert.AreEqual(0.6, layer.Style.Opacity);
        }
        private string GetGeoJson_BBox(BoundingBoxQuery query, Metrics metrics, string tableName)
        {
            string strOut = null;

            metrics.Start("Init");
            LayerStyle            style  = new LayerStyle(query.FillColor, query.StrokeColor, query.strokeThickness);
            GeoJSONGeometryWriter writer = null;

            try
            {
                //bool useGeography = rdr.GetFieldType(0).Name == "SqlGeography";
                PrecisionReducerCoordinateConverter coordConverter = new PrecisionReducerCoordinateConverter(query.BBox, query.Width, query.Height);
                writer = new GeoJSONGeometryWriter();
                writer.Init(coordConverter, query.Width, query.Height, style, metrics);

                DataService svc = new DataService(this.UseInMemoryCache, this.MetricsType, this.GeometryReduce, this.GeometryRemoveArtefacts, this.GeometryClip);
                strOut = svc.GetObjectGeneric_FromCacheBBox <string, double[]>(query, metrics, tableName, writer);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Dispose();
                    writer = null;
                }
            }
            return(strOut);
        }
Example #10
0
        public void AdjustmentLayerWithSpecifiedLayerStyleHasSpecifiedLayerStyle()
        {
            var layer = new AdjustmentLayer(LayerStyle.Add(0.6), CreateTestEffect());

            Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
            Assert.AreEqual(0.6, layer.Style.Opacity);
        }
Example #11
0
        public FantasticEffect()
        {
            var globalCurve = new Curve(CurveInterpolation.NaturalCubicSpline)
            {
                Points = new[]
                {
                    new Point(0, 0),
                    new Point(68, 60),
                    new Point(144, 163),
                    new Point(255, 255),
                }
            };

            var overlayFactory1 = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Fantastic1.jpg",
                "ms-appx:///images/Filters_Portrait_Overlay_Fantastic1.jpg",
                "ms-appx:///images/Filters_Square_Overlay_Fantastic1.jpg");

            var overlayFactory2 = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Fantastic2.png",
                "ms-appx:///images/Filters_Portrait_Overlay_Fantastic2.png",
                "ms-appx:///images/Filters_Square_Overlay_Fantastic2.png");

            LayerList = new LayerList()
            {
                new AdjustmentLayer(LayerStyle.Normal(), new ContrastEffect(1.0)),
                new AdjustmentLayer(LayerStyle.Normal(), new CurvesEffect(globalCurve)),
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect(0.54, 0.64, 0.0, -0.1)),
                new Layer(LayerStyle.Softlight(), context => overlayFactory1.CreateAsync(context.BackgroundLayer.ImageSize)),
                new Layer(LayerStyle.Normal(), context => overlayFactory2.CreateAsync(context.BackgroundLayer.ImageSize))
            };
        }
Example #12
0
        public BWEffect()
        {
            var curvesEffect = new CurvesEffect(new Curve(CurveInterpolation.NaturalCubicSpline)
            {
                Points = new[]
                {
                    new Point(0, 0),
                    new Point(41, 59),
                    new Point(112, 146),
                    new Point(189, 211),
                    new Point(255, 255),
                }
            });

            m_lomoStack = new LayerList()
            {
                new AdjustmentLayer(LayerStyle.Normal(), new LomoEffect(0.3, 0.0, LomoVignetting.High, LomoStyle.Neutral))
            };

            LayerList = new LayerList()
            {
                new AdjustmentLayer(LayerStyle.Normal(), curvesEffect),
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect()),
                new AdjustmentLayer(LayerStyle.Normal(), new SharpnessEffect(0.15)),
                new Layer(LayerStyle.Hardlight(0.1), context => m_lomoStack.ToImageProvider(context.BackgroundImage, context.HintedRenderSize))
            };
        }
Example #13
0
        public DreamEffect()
        {
            Name = "Dream";

            var diagonalGradient = new LinearGradient
            {
                StartPoint = new Point(0.0, 0.0),
                EndPoint   = new Point(1.0, 1.0),

                Stops = new[]
                {
                    new GradientStop {
                        Offset = 0, Color = Color.FromArgb(255, 133, 147, 201)
                    },
                    new GradientStop {
                        Offset = 1.0, Color = Color.FromArgb(255, 245, 152, 157)
                    }
                }
            };

            var overlayFactory = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Dream.jpg",
                "ms-appx:///images/Filters_Portrait_Overlay_Dream.jpg",
                "ms-appx:///images/Filters_Square_Overlay_Dream.jpg");

            LayerList = new LayerList(
                new AdjustmentLayer(LayerStyle.Normal(), new LevelsEffect(0.75, 0.85, 0.15)),
                new Layer(LayerStyle.Softlight(), context => new GradientImageSource(context.BackgroundLayer.ImageSize, diagonalGradient)),
                new Layer(LayerStyle.Overlay(), context => overlayFactory.CreateAsync(context.BackgroundLayer.ImageSize))
                );
        }
        private Bitmap GetImage_BBox(BoundingBoxQuery query, Metrics metrics, string tableName)
        {
            Bitmap bmpOut = null;

            metrics.Start("Init");
            LayerStyle style = new LayerStyle(query.FillColor, query.StrokeColor, query.strokeThickness);
            GDIBitmapGeometryWriter writer = null;

            try
            {
                //bool useGeography = rdr.GetFieldType(0).Name == "SqlGeography";
                BitmapCoordConverter coordConverter = new BitmapCoordConverter(query.Width, query.Height, query.BBox);
                writer = new GDIBitmapGeometryWriter(SmoothingMode.AntiAlias, coordConverter);
                writer.Init(query.Width, query.Height, style, metrics);

                DataService svc = new DataService(this.UseInMemoryCache, this.MetricsType, this.GeometryReduce, this.GeometryRemoveArtefacts, this.GeometryClip);
                bmpOut = svc.GetObjectGeneric_FromCacheBBox <Bitmap, System.Drawing.Point>(query, metrics, tableName, writer);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Dispose();
                    writer = null;
                }
            }
            return(bmpOut);
        }
        private List <SqlGeometry> GetGeometries_BBox(BoundingBoxQuery query, Metrics metrics, string tableName)
        {
            List <SqlGeometry> outList = null;

            metrics.Start("Init");
            LayerStyle        style  = new LayerStyle(query.FillColor, query.StrokeColor, query.strokeThickness);
            SqlGeometryWriter writer = null;

            try
            {
                //bool useGeography = rdr.GetFieldType(0).Name == "SqlGeography";
                writer = new SqlGeometryWriter();


                DataService svc = new DataService(this.UseInMemoryCache, this.MetricsType, this.GeometryReduce, this.GeometryRemoveArtefacts, this.GeometryClip);
                outList = svc.GetObjectGeneric_FromCacheBBox(query, metrics, tableName, writer);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Dispose();
                    writer = null;
                }
            }
            return(outList);
        }
        public void LayerWithSpecifiedLayerStyleHasSpecifiedLayerStyle()
        {
            var layer = new Layer(LayerStyle.Add(0.6), CreateTestImageProvider());

            Assert.AreEqual(BlendFunction.Add, layer.Style.BlendFunction);
            Assert.AreEqual(0.6, layer.Style.Opacity);
        }
Example #17
0
        public LightEffect()
        {
            var globalCurve = new Curve(CurveInterpolation.Linear, new[]
            {
                new Point(0, 0),
                new Point(41, 59),
                new Point(112, 146),
                new Point(189, 211),
                new Point(255, 255)
            });

            var redCurve = new Curve(CurveInterpolation.Linear, new[]
            {
                new Point(18, 0),
                new Point(126, 116),
                new Point(255, 228),
            });

            Curve.Compose(redCurve, globalCurve, redCurve);

            var greenCurve = globalCurve;

            var blueCurve = new Curve(CurveInterpolation.Linear, new[]
            {
                new Point(0, 44),
                new Point(113, 138),
                new Point(230, 255),
            });

            Curve.Compose(blueCurve, globalCurve, blueCurve);

            var gradient = new RadialGradient
            {
                EllipseRadius = new EllipseRadius(1.5, 0),
                CenterPoint   = new Point(0.5, 0.5),
                Stops         = new[]
                {
                    new GradientStop {
                        Offset = 0, Color = Color.FromArgb(0, 0, 0, 0)
                    },
                    new GradientStop {
                        Offset = 1, Color = Color.FromArgb(255, 255, 255, 255)
                    }
                }
            };

            var overlayFactory = new OverlayFactory(
                "ms-appx:///images/Filters_Landscape_Overlay_Light.jpg",
                "ms-appx:///images/Filters_Portrait_Overlay_Light.jpg",
                "ms-appx:///images/Filters_Square_Overlay_Light.jpg");

            LayerList = new LayerList()
            {
                new AdjustmentLayer(LayerStyle.Normal(0.2), new CurvesEffect(redCurve, greenCurve, blueCurve)),
                new Layer(LayerStyle.Softlight(0.3), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 200, 200, 200))),
                new Layer(LayerStyle.Softlight(0.7), context => new GradientImageSource(context.BackgroundLayer.ImageSize, gradient)),
                new Layer(LayerStyle.Screen(), context => overlayFactory.CreateAsync(context.BackgroundLayer.ImageSize))
            };
        }
 public void LayerListCanBeCreatedWithLayers()
 {
     var layerList = new LayerList(new Layer[]
     {
         new Layer(LayerStyle.Add(0.5), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 128, 128, 128))),
         new AdjustmentLayer(LayerStyle.Normal(), new BrightnessEffect(0.9))
     });
 }
Example #19
0
        protected override void AddSpot(Point pos, IFeature f)
        {
            double          radius   = LayerStyle.SpotSize / 2;
            EllipseGeometry geometry = new EllipseGeometry(pos, radius, radius);
            GeometryDrawing drawing  = new GeometryDrawing(LayerStyle.GetFill(), new Pen(LayerStyle.Stroke, LayerStyle.StrokeWeight), geometry);

            this.AddFeatureChildren(f, drawing);
        }
Example #20
0
 public SketchEffect()
 {
     LayerList.AddRange(new Layer[]
     {
         new AdjustmentLayer(LayerStyle.Normal(0.64), new GrayscaleEffect(0.23, 0.60, 0.33, -0.1)),
         new AdjustmentLayer(LayerStyle.Multiply(), new Lumia.Imaging.Artistic.SketchEffect(SketchMode.Gray))
     });
 }
Example #21
0
 /// <summary>
 /// Создаёт объект класса Layer
 /// </summary>
 /// <param name="number">Порядковый номер</param>
 /// <param name="size">Количество нейронов в слое</param>
 /// <param name="style">Вид слоя:1 слой-входной; последний-выходной; остальные-скрытые</param>
 public Layer(int number, int size, LayerStyle style) : this()
 {
     for (int i = 0; i < size; i++)
     {
         this.neurons.Add(new Neuron(Convert.ToString("слой " + number + " номер " + (i + 1)), style == LayerStyle.input ? true : false, style != LayerStyle.output && i == 1 ? true : false));
     }
     this.Style  = style;
     this.Number = number;
 }
 public LoSatWarmEffect()
 {
     LayerList.AddRange(
         new Layer(LayerStyle.Overlay(0.1), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 255, 242, 0))),
         new AdjustmentLayer(LayerStyle.Normal(0.45), new GrayscaleEffect(0.35, 0.66, 0.0, -0.05)),
         new AdjustmentLayer(LayerStyle.Normal(), Lookups.LoSatWarmCurvesEffect),
         new Layer(LayerStyle.Softlight(0.5), context => Lookups.LoSatWarmVignette.GetAsync(context.BackgroundLayer.ImageSize))
         );
 }
 public void LayerListCanBeCreatedWithBackgroundImageAndLayers()
 {
     var backgroundImage = new ColorImageSource(new Size(100, 100), Colors.AliceBlue);
     var layerList       = new LayerList(backgroundImage, backgroundImage.ImageSize, new Layer[]
     {
         new Layer(LayerStyle.Add(0.5), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 128, 128, 128))),
         new AdjustmentLayer(LayerStyle.Normal(), new BrightnessEffect(0.9))
     });
 }
        private LayerContext CreateFakeLayerContext(Layer layer)
        {
            var backgroundImage = new ColorImageSource(BackgroundLayerSize, Colors.AliceBlue);
            var backgroundLayer = new Layer(LayerStyle.Normal(), backgroundImage, BackgroundLayerSize);
            var invariants      = new LayerContext.Invariants(backgroundLayer, new MaybeTask <IImageProvider>(backgroundImage), new Size(0, 0));
            var layerContext    = new LayerContext(invariants, backgroundLayer, layer, 1);

            layerContext.PreviousImage = layerContext.BackgroundImage;
            return(layerContext);
        }
        public BWCopperEffect()
        {
            LayerList.AddRange(
                // Channel mixer
                new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect(0.54, 0.64, 0.0, -0.1)),

                // "Curves 1" and "Layer 1".
                new AdjustmentLayer(LayerStyle.Normal(), Lookups.CopperCurvesEffect)
                );
        }
Example #26
0
        protected virtual void AddRoadFill(Point[] points, IFeature f)
        {
            Polyline poly = new Polyline();

            points.ForEach(p => poly.Points.Add(p));
            poly.Stroke          = LayerStyle.GetFill(f);
            poly.StrokeThickness = LayerStyle.StrokeWeight;
            poly.StrokeLineJoin  = PenLineJoin.Bevel;
            Children.Add(poly);
        }
Example #27
0
 protected override void AddPolygon(Point[] points, IFeature f)
 {
     if (points.First() != points.Last()) // newly 20140624
     {
         var pts = points.ToList();
         pts.Add(pts.First());
         points = pts.ToArray();
     }
     AddPolylineInternal(points, f, LayerStyle.GetFill(), LayerStyle.Stroke, LayerStyle.StrokeWeight);
 }
Example #28
0
        protected virtual void AddPolygon(Point[] points, IFeature f)
        {
            Polygon poly = new Polygon();

            points.ForEach(p => poly.Points.Add(p));
            poly.Stroke          = LayerStyle.Stroke;
            poly.StrokeThickness = LayerStyle.StrokeWeight;
            poly.StrokeLineJoin  = PenLineJoin.Bevel;
            poly.Fill            = LayerStyle.GetFill(f);
            this.AddFeatureChildren(f, poly);
        }
        public void LayersCanBeAddedWithAddRange()
        {
            var layerList = new LayerList();

            layerList.AddRange(new[]
            {
                new Layer(LayerStyle.Add(0.5), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 128, 128, 128))),
                new AdjustmentLayer(LayerStyle.Normal(), new FilterEffect {
                    Filters = new IFilter[] { new BrightnessFilter(0.9) }
                })
            });
        }
Example #30
0
        public void CreateWithTaskMask()
        {
            var mask = new ColorImageSource(new Size(100, 100), Colors.AliceBlue);
            var rect = new Rect(1, 2, 3, 4);

            var layerStyle = new LayerStyle(BlendFunction.Screen, 0.7, Task.FromResult <IImageProvider>(mask), rect);

            Assert.AreEqual(BlendFunction.Screen, layerStyle.BlendFunction);
            Assert.AreEqual(0.7, layerStyle.Opacity);
            Assert.AreSame(mask, layerStyle.MaskResolver(null).Result);
            Assert.AreEqual(rect, layerStyle.TargetArea);
        }