Enable antialiasing based on EdgeMode in DrawBitmap (#20116)
* Enable antialiasing based on EdgeMode in DrawBitmap * Update expected image for ImageBrush Tile UniformToFill test * Add tests for rotated image with EdgeMode options * Add expected images for Direct2D1 image rotation tests * Revert "Add expected images for Direct2D1 image rotation tests" This reverts commit 63dd6717b0ff4488ee7b453f220e3329202ec9d2. * Remove Direct2D1 in ImageTests --------- Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
This commit is contained in:
@@ -251,6 +251,7 @@ namespace Avalonia.Skia
|
||||
|
||||
paint.Color = new SKColor(255, 255, 255, (byte)(255 * opacity * _currentOpacity));
|
||||
paint.BlendMode = RenderOptions.BitmapBlendingMode.ToSKBlendMode();
|
||||
paint.IsAntialias = RenderOptions.EdgeMode != EdgeMode.Aliased;
|
||||
|
||||
drawableImage.Draw(this, s, d, samplingOptions, paint);
|
||||
SKPaintCache.Shared.ReturnReset(paint);
|
||||
|
||||
@@ -10,11 +10,13 @@ namespace Avalonia.Skia.RenderTests
|
||||
public class ImageTests : TestBase
|
||||
{
|
||||
private readonly Bitmap _bitmap;
|
||||
private readonly Bitmap _bitmap2;
|
||||
|
||||
public ImageTests()
|
||||
: base(@"Controls\Image")
|
||||
{
|
||||
_bitmap = new Bitmap(Path.Combine(OutputPath, "test.png"));
|
||||
_bitmap2 = new Bitmap(Path.Combine(OutputPath, "test2.png"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -108,5 +110,68 @@ namespace Avalonia.Skia.RenderTests
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Image_Rotated_EdgeMode_Unspecified()
|
||||
{
|
||||
Decorator target = new Decorator
|
||||
{
|
||||
Padding = new Thickness(32, 32),
|
||||
Width = 200,
|
||||
Height = 200,
|
||||
Child = new Image
|
||||
{
|
||||
Source = _bitmap2,
|
||||
Stretch = Stretch.Uniform,
|
||||
RenderTransform = new RotateTransform(30),
|
||||
}
|
||||
};
|
||||
RenderOptions.SetEdgeMode(target, EdgeMode.Unspecified);
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Image_Rotated_EdgeMode_Antialias()
|
||||
{
|
||||
Decorator target = new Decorator
|
||||
{
|
||||
Padding = new Thickness(32, 32),
|
||||
Width = 200,
|
||||
Height = 200,
|
||||
Child = new Image
|
||||
{
|
||||
Source = _bitmap2,
|
||||
Stretch = Stretch.Uniform,
|
||||
RenderTransform = new RotateTransform(30),
|
||||
}
|
||||
};
|
||||
RenderOptions.SetEdgeMode(target, EdgeMode.Antialias);
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Image_Rotated_EdgeMode_Aliased()
|
||||
{
|
||||
Decorator target = new Decorator
|
||||
{
|
||||
Padding = new Thickness(32, 32),
|
||||
Width = 200,
|
||||
Height = 200,
|
||||
Child = new Image
|
||||
{
|
||||
Source = _bitmap2,
|
||||
Stretch = Stretch.Uniform,
|
||||
RenderTransform = new RotateTransform(30),
|
||||
}
|
||||
};
|
||||
RenderOptions.SetEdgeMode(target, EdgeMode.Aliased);
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 370 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |
Reference in New Issue
Block a user