* Add missing Bitmap Blend Modes supported by Skia * Expose Blend Mode on Image Control * Fix image render options "push" not being disposed Fix image blendMode change not triggering a re-render * Add Image Blend Tests * Remove Modulate Blend mode * Add Composition Blend Modes Tests --------- Co-authored-by: Benedikt Stebner <Gillibald@users.noreply.github.com>repro/18104-drag-drop-flyout-placement
@ -0,0 +1,83 @@ |
|||
using System.IO; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Media; |
|||
using Avalonia.Media.Imaging; |
|||
using Xunit; |
|||
|
|||
#if AVALONIA_SKIA
|
|||
namespace Avalonia.Skia.RenderTests |
|||
#else
|
|||
namespace Avalonia.Direct2D1.RenderTests.Controls |
|||
#endif
|
|||
{ |
|||
public class ImageBlendTests : TestBase |
|||
{ |
|||
private readonly Bitmap _bitmapBase; |
|||
private readonly Bitmap _bitmapOver; |
|||
|
|||
public ImageBlendTests() |
|||
: base(@"Controls\Image\blend") |
|||
{ |
|||
_bitmapBase = new Bitmap(Path.Combine(OutputPath, "Cat.jpg")); |
|||
_bitmapOver = new Bitmap(Path.Combine(OutputPath, "ColourShading - by Stib.png")); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Image_Blend_Nothing() => await TestBlendMode(BitmapBlendingMode.Unspecified); |
|||
[Fact] |
|||
public async Task Image_Blend_Plus() => await TestBlendMode(BitmapBlendingMode.Plus); |
|||
[Fact] |
|||
public async Task Image_Blend_Screen() => await TestBlendMode(BitmapBlendingMode.Screen); |
|||
[Fact] |
|||
public async Task Image_Blend_Overlay() => await TestBlendMode(BitmapBlendingMode.Overlay); |
|||
[Fact] |
|||
public async Task Image_Blend_Darken() => await TestBlendMode(BitmapBlendingMode.Darken); |
|||
[Fact] |
|||
public async Task Image_Blend_Lighten() => await TestBlendMode(BitmapBlendingMode.Lighten); |
|||
[Fact] |
|||
public async Task Image_Blend_ColorDodge() => await TestBlendMode(BitmapBlendingMode.ColorDodge); |
|||
[Fact] |
|||
public async Task Image_Blend_ColorBurn() => await TestBlendMode(BitmapBlendingMode.ColorBurn); |
|||
[Fact] |
|||
public async Task Image_Blend_HardLight() => await TestBlendMode(BitmapBlendingMode.HardLight); |
|||
[Fact] |
|||
public async Task Image_Blend_SoftLight() => await TestBlendMode(BitmapBlendingMode.SoftLight); |
|||
[Fact] |
|||
public async Task Image_Blend_Difference() => await TestBlendMode(BitmapBlendingMode.Difference); |
|||
[Fact] |
|||
public async Task Image_Blend_Exclusion() => await TestBlendMode(BitmapBlendingMode.Exclusion); |
|||
[Fact] |
|||
public async Task Image_Blend_Multiply() => await TestBlendMode(BitmapBlendingMode.Multiply); |
|||
[Fact] |
|||
public async Task Image_Blend_Hue() => await TestBlendMode(BitmapBlendingMode.Hue); |
|||
[Fact] |
|||
public async Task Image_Blend_Saturation() => await TestBlendMode(BitmapBlendingMode.Saturation); |
|||
[Fact] |
|||
public async Task Image_Blend_Color() => await TestBlendMode(BitmapBlendingMode.Color); |
|||
[Fact] |
|||
public async Task Image_Blend_Luminosity() => await TestBlendMode(BitmapBlendingMode.Luminosity); |
|||
|
|||
private async Task TestBlendMode(BitmapBlendingMode blendMode, [CallerMemberName] string testName = "") |
|||
{ |
|||
var panel = new Panel(); |
|||
panel.Children.Add(new Image() { Source = _bitmapBase }); |
|||
panel.Children.Add(new Image() { Source = _bitmapOver, BlendMode = blendMode }); |
|||
|
|||
var target = new Decorator |
|||
{ |
|||
Width = 512, |
|||
Height = 512, |
|||
Child = new Border |
|||
{ |
|||
Background = Brushes.Red, |
|||
Child = panel |
|||
} |
|||
}; |
|||
|
|||
await RenderToFile(target,testName); |
|||
CompareImages(testName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using System.IO; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Media; |
|||
using Avalonia.Media.Imaging; |
|||
using Xunit; |
|||
|
|||
#if AVALONIA_SKIA
|
|||
namespace Avalonia.Skia.RenderTests |
|||
#else
|
|||
namespace Avalonia.Direct2D1.RenderTests.Controls |
|||
#endif
|
|||
{ |
|||
public class ImageCompositionTests : TestBase |
|||
{ |
|||
private readonly Bitmap _bitmapA; |
|||
private readonly Bitmap _bitmapB; |
|||
|
|||
public ImageCompositionTests() |
|||
: base(@"Controls\Image\composition") |
|||
{ |
|||
_bitmapA = new Bitmap(Path.Combine(OutputPath, "A.png")); |
|||
_bitmapB = new Bitmap(Path.Combine(OutputPath, "B.png")); |
|||
} |
|||
[Fact] |
|||
public async Task Image_Blend_SourceOver() => await TestCompositeMode(BitmapBlendingMode.SourceOver); |
|||
[Fact] |
|||
public async Task Image_Blend_Source() => await TestCompositeMode(BitmapBlendingMode.Source); |
|||
[Fact] |
|||
public async Task Image_Blend_SourceIn() => await TestCompositeMode(BitmapBlendingMode.SourceIn); |
|||
[Fact] |
|||
public async Task Image_Blend_SourceOut() => await TestCompositeMode(BitmapBlendingMode.SourceOut); |
|||
[Fact] |
|||
public async Task Image_Blend_SourceAtop() => await TestCompositeMode(BitmapBlendingMode.SourceAtop); |
|||
[Fact] |
|||
public async Task Image_Blend_Destination() => await TestCompositeMode(BitmapBlendingMode.Destination); |
|||
[Fact] |
|||
public async Task Image_Blend_DestinationIn() => await TestCompositeMode(BitmapBlendingMode.DestinationIn); |
|||
[Fact] |
|||
public async Task Image_Blend_DestinationOut() => await TestCompositeMode(BitmapBlendingMode.DestinationOut); |
|||
[Fact] |
|||
public async Task Image_Blend_DestinationOver() => await TestCompositeMode(BitmapBlendingMode.DestinationOver); |
|||
[Fact] |
|||
public async Task Image_Blend_DestinationAtop() => await TestCompositeMode(BitmapBlendingMode.DestinationAtop); |
|||
[Fact] |
|||
public async Task Image_Blend_Xor() => await TestCompositeMode(BitmapBlendingMode.Xor); |
|||
|
|||
private async Task TestCompositeMode(BitmapBlendingMode blendMode, [CallerMemberName] string testName = "") |
|||
{ |
|||
var panel = new Panel(); |
|||
panel.Children.Add(new Image() { Source = _bitmapA }); |
|||
panel.Children.Add(new Image() { Source = _bitmapB, BlendMode = blendMode }); |
|||
|
|||
var target = new Decorator |
|||
{ |
|||
Width = 512, |
|||
Height = 512, |
|||
Child = new Border |
|||
{ |
|||
Background = Brushes.Transparent, |
|||
Child = panel |
|||
} |
|||
}; |
|||
|
|||
await RenderToFile(target,testName); |
|||
CompareImages(testName); |
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 240 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 240 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 353 KiB |
|
After Width: | Height: | Size: 306 KiB |
|
After Width: | Height: | Size: 319 KiB |
|
After Width: | Height: | Size: 327 KiB |
|
After Width: | Height: | Size: 424 KiB |
|
After Width: | Height: | Size: 397 KiB |
|
After Width: | Height: | Size: 301 KiB |
|
After Width: | Height: | Size: 382 KiB |
|
After Width: | Height: | Size: 288 KiB |
|
After Width: | Height: | Size: 296 KiB |
|
After Width: | Height: | Size: 341 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 387 KiB |
|
After Width: | Height: | Size: 299 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 338 KiB |
|
After Width: | Height: | Size: 405 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 20 KiB |