microsoft / microsoft/microsoft-ui-xaml

No antialias in Image in very specific case

Open
#10,870 2 comments 0 reactions 0 assignees View on GitHub
area-Images bug
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

The image is no antialiased when loaded from code in the following specific case. In the following screenshot you can clearly see the difference.

Image

### Why is this important?

The image loaded in such way looks like early 2000, it contrasts with Fluent UI.

### Steps to reproduce the bug

``` xaml


````

``` csharp
StorageFile fi = await StorageFile.GetFileFromPathAsync("..../github.png");

BitmapImage bitmapImage1 = new();
using IRandomAccessStream stream = await fi.OpenAsync(FileAccessMode.Read);
await bitmapImage1.SetSourceAsync(stream);
PixelatedImage.Source = bitmapImage1;

BitmapImage bitmapImage2 = new();
using IRandomAccessStream stream2 = await fi.OpenAsync(FileAccessMode.Read);
GoodImage.Source = bitmapImage2;
await bitmapImage2.SetSourceAsync(stream2);
```

The difference betwween the 2 is the order between `Source` assignation and `BitmapImage.SetSourceAsync`.

### Actual behavior

The actual behavior is visibile in the screenshot.

### Expected behavior

_No response_

### Screenshots

Image

### NuGet package version

WinUI 3 - Windows App SDK 1.8.2: 1.8.251003001

### Windows version

Windows 10 (21H2): Build 19044

### Additional context

A very similar issue was already present in uwp https://stackoverflow.com/questions/42189063/image-smoothing-in-uwp-app

Contributor guide

Open the contributing guide

Research direction

Start with the two XAML Image elements and the C# BitmapImage.SetSourceAsync sequences in the reproduction, then compare behavior when Source is assigned before versus after loading. Done means the two loading orders produce the same antialiased rendering on the stated WinUI 3 and Windows version.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.