dotnet / dotnet/wpf

Artifacts when using BitmapCacheBrush

Open
#9,161 4 comments 1 reaction 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Using [BitmapCacheBrush](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.bitmapcachebrush?view=windowsdesktop-8.0) you can _singificantly_ improve rendering performance of complex shapes. However, for some shapes, you get undesired artifacts. Please see attached [sample project](https://github.com/dotnet/wpf/files/15456096/WpfBitmapCacheBrushBug.zip).

It seems pixels leak from the edges.
![image](https://github.com/dotnet/wpf/assets/958469/7e69bdc1-53a3-4e43-8cdb-67ea5c2b91ad)

With some experience from the OpenGL world, I'd guess this has something to do with texture repeat mode. For our use case, we certainly don't want the brush to repeat. All in all, this looks like a `WPF` rendering bug.

### Reproduction Steps

See attached sample project. Run it, and observe the artifacts.

[WpfBitmapCacheBrushBug.zip](https://github.com/dotnet/wpf/files/15456096/WpfBitmapCacheBrushBug.zip)

### Expected behavior

Rendering a shape using `BitmapCacheBrush` should not cause pixels to leak to the other side of the image.

### Actual behavior

`BitmapCacheBrush` causes visual artifacts.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

The `BitmapCacheBrush` is a powerful feature which allows you to cache and quickly render e.g. complex vector images. We successfully integrated it with our heavy Enterprise desktop app, allowing for unprecedented rendering performance in our data grid.

Having these visual artifacts is a bit of a bummer. There is no other way to get the same rendering performance for our vector images.

### Configuration

* Windows 10 22H2
* .NET 6 (same behavior on .NET 8)

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.