A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.2 KiB

using System.IO;
using System.Runtime.CompilerServices;
using Avalonia.Media.Imaging;
using CrossUI;
#if AVALONIA_SKIA
namespace Avalonia.Skia.RenderTests.CrossTests;
#elif AVALONIA_D2D
namespace Avalonia.Direct2D1.RenderTests.CrossTests;
#else
namespace Avalonia.RenderTests.WpfCompare.CrossTests;
#endif
public class ImageScalingTests() : CrossTestBase("Media/ImageScaling")
{
[CrossFact]
public void Upscaling_With_HighQuality_Should_Be_Antialiased()
=> TestHighQualityScaling(1024);
[CrossFact]
public void Downscaling_With_HighQuality_Should_Be_Antialiased()
=> TestHighQualityScaling(128);
private void TestHighQualityScaling(int size, [CallerMemberName] string? testName = null)
{
var directoryPath = Path.GetDirectoryName(typeof(ImageScalingTests).Assembly.Location);
var imagePath = Path.Join(directoryPath, "Assets", "Star512.png");
RenderAndCompare(
new CrossImageControl
{
Width = size,
Height = size,
Image = new CrossBitmapImage(imagePath),
BitmapInterpolationMode = BitmapInterpolationMode.HighQuality
},
testName);
}
}