Performance BitmapImage vs. ImageBrush

I tried to search, but I could not find the answer to this question: are there any improvements in using ImageBrush to fill the rectangle, and not to create BitmapImage and set its source property?

I have to display a large number of images (we are trying to click more than 5000), and so far I am creating them as follows:

<Image x:Name="img" RenderOptions.BitmapScalingMode="LowQuality" Source="{Binding Path, Converter={StaticResource StringToImageConverter}, ConverterParameter={StaticResource string}}" > </ext:IdImage> 

and in the converter:

 System.Windows.Media.Imaging.BitmapImage image = new System.Windows.Media.Imaging.BitmapImage(); image.BeginInit(); image.UriSource = new Uri(value as String); image.DecodePixelWidth = int.Parse((String)parameter); image.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad; image.EndInit(); return image; 

Note. I need to use a converter to set the DecodePixelWidth property.

Using ImageBrush, I could freeze the brush this way, according to what I read, increasing performance, so I was wondering if I should change the way I create images.

PS Images are not static, but translated.

+5
source share
1 answer

I think the problem is not in the code, but in the WPF architecture.

If your problem is related to performance, then for my personal experience XAML development is necessary so that the computer is preferably equipped with a dedicated graphics card. However, many times, even in a very old PC with Windows XP for a thin program, I installed direct X library updates

http://support.microsoft.com/kb/179113/en

XAML is based on directX

Give it a try and let me know.

0
source

Source: https://habr.com/ru/post/1204306/


All Articles