/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayResolver">A lazy resolve func that returns an array of <see cref="IFilter" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func <LayerContext, Task <IFilter[]> > filterArrayResolver) : base(layerStyle, context => new MaybeTask <IImageProvider>(filterArrayResolver(context).ContinueWith( (Func <Task <IFilter[]>, IImageProvider>)CreateFilterEffectFromFilterArrayTask, ContinuationOptions)), Size.Empty) { }
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); }
private Layer GetActiveBackgroundLayer(MaybeTask <IImageProvider> backgroundImage, Size backgroundImageSize) { var backgroundLayer = this[0]; // Replace BG layer? if (!backgroundImage.IsEmpty) { if (backgroundLayer != EmptyLayer) { throw new ArgumentException("LayerList was constructed with a background image, do not pass one into ToImageProvider.", "backgroundImage"); } backgroundLayer = new Layer(LayerStyle.Normal(), backgroundImage, backgroundImageSize); } return(backgroundLayer); }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayResolver">A lazy resolve func that returns an array of <see cref="IFilter" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func<LayerContext, IFilter[]> filterArrayResolver) : base(layerStyle, context => new MaybeTask<IImageProvider>(new FilterEffect { Filters = filterArrayResolver(context) }), Size.Empty) { }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayTask">An already started task that results in an array of <see cref="IFilter" /> to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Task<IFilter[]> filterArrayTask) : this(layerStyle, context => filterArrayTask) { }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Func <LayerContext, MaybeTask <IImageProvider> > imageProviderResolver, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = imageProviderResolver; ImageSize = imageSize; }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectResolver">A lazy resolve func that asynchronously returns the effect <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func<LayerContext, Task<IImageProvider>> effectResolver) : base(layerStyle, context => new MaybeTask<IImageProvider>(effectResolver(context)), Size.Empty) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectTask">An already started task that asynchronously results in the effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Task<IImageProvider> effectTask) : base(layerStyle, context => new MaybeTask<IImageProvider>(effectTask), Size.Empty) { }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Func<LayerContext, IImageProvider> imageProviderResolver, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => new MaybeTask<IImageProvider>(imageProviderResolver(context)); ImageSize = imageSize; }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderTask">An already started task that asynchronously results in an <see cref="IImageProvider" /> that is the image content.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Task<IImageProvider> imageProviderTask, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => new MaybeTask<IImageProvider>(imageProviderTask); ImageSize = imageSize; }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayResolver">A lazy resolve func that returns an array of <see cref="IFilter" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func <LayerContext, IFilter[]> filterArrayResolver) : base(layerStyle, context => new MaybeTask <IImageProvider>(new FilterEffect { Filters = filterArrayResolver(context) }), Size.Empty) { }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayResolver">A lazy resolve func that returns an array of <see cref="IFilter" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func<LayerContext, Task<IFilter[]>> filterArrayResolver) : base(layerStyle, context => new MaybeTask<IImageProvider>(filterArrayResolver(context).ContinueWith( (Func<Task<IFilter[]>, IImageProvider>)CreateFilterEffectFromFilterArrayTask, ContinuationOptions)), Size.Empty) { }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filterArrayTask">An already started task that results in an array of <see cref="IFilter" /> to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Task <IFilter[]> filterArrayTask) : this(layerStyle, context => filterArrayTask) { }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filters">One or more filters to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, params IFilter[] filters) : this(layerStyle, context => filters) { }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Func <LayerContext, IImageProvider> imageProviderResolver, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => new MaybeTask <IImageProvider>(imageProviderResolver(context)); ImageSize = imageSize; }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProvider">A value that represents either the <see cref="IImageProvider" /> that is the image content or a task that asynchronously results in it.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, MaybeTask <IImageProvider> imageProvider, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => imageProvider; ImageSize = imageSize; }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderTask">An already started task that asynchronously results in an <see cref="IImageProvider" /> that is the image content.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Task <IImageProvider> imageProviderTask, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => new MaybeTask <IImageProvider>(imageProviderTask); ImageSize = imageSize; }
/// <summary> /// Creates a LayerList with a specified background image. /// </summary> /// <param name="backgroundImage">The image to use for the background layer.</param> /// <param name="backgroundImageSize">Optionally, the size of the background image. If omitted, the natural size of the source will be used, but the size will not available in the LayerLinkingContext for lazy resolvers.</param> /// <param name="layers">A list of layers to add following the background layer.</param> public LayerList(IImageProvider backgroundImage, Size backgroundImageSize, params Layer[] layers) { Add(new Layer(LayerStyle.Normal(), new MaybeTask <IImageProvider>(backgroundImage), backgroundImageSize)); AddRange(layers); }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effect">The effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, IImageProvider effect) : this(layerStyle, context => effect) { }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, Func<LayerContext, MaybeTask<IImageProvider>> imageProviderResolver, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = imageProviderResolver; ImageSize = imageSize; }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectTask">An already started task that asynchronously results in the effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Task <IImageProvider> effectTask) : base(layerStyle, context => new MaybeTask <IImageProvider>(effectTask), Size.Empty) { }
/// <summary> /// Creates a layer with image content. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="imageProvider">A value that represents either the <see cref="IImageProvider" /> that is the image content or a task that asynchronously results in it.</param> /// <param name="imageSize">Optional, the size of the image content of the layer.</param> public Layer(LayerStyle layerStyle, MaybeTask<IImageProvider> imageProvider, Size imageSize = default(Size)) { Style = layerStyle; GetImageProvider = context => imageProvider; ImageSize = imageSize; }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectTask">An already started task that asynchronously results in the effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, MaybeTask <IImageProvider> effectTask) : base(layerStyle, effectTask, Size.Empty) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effect">The effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, IImageProvider effect) : this(layerStyle, context => effect) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectResolver">A lazy resolve func that asynchronously returns the effect <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func <LayerContext, Task <IImageProvider> > effectResolver) : base(layerStyle, context => new MaybeTask <IImageProvider>(effectResolver(context)), Size.Empty) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectTask">An already started task that asynchronously results in the effect to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, MaybeTask<IImageProvider> effectTask) : base(layerStyle, effectTask, Size.Empty) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectResolver">A lazy resolve func that asynchronously returns the effect <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func <LayerContext, MaybeTask <IImageProvider> > effectResolver) : base(layerStyle, effectResolver, Size.Empty) { }
/// <summary> /// Creates an adjustment layer containing the specified effect. /// </summary> /// <param name="layerStyle">Layer style to use for this layer.</param> /// <param name="effectResolver">A lazy resolve func that asynchronously returns the effect <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, Func<LayerContext, MaybeTask<IImageProvider>> effectResolver) : base(layerStyle, effectResolver, Size.Empty) { }
/// <summary> /// Adds an adjustment layer, with one or more filters, blended onto the previous layer. /// </summary> /// <param name="layerStyle">Description of how to blend this layer onto the preceding one.</param> /// <param name="filters">One or more filters to apply in the adjustment layer.</param> /// <returns>The adjustment layer.</returns> public AdjustmentLayer(LayerStyle layerStyle, params IFilter[] filters) : this(layerStyle, context => filters) { }