WPF and very large images

Is there anything I can do to help manage the huge amount of memory that WPF uses to render huge images - maybe something up to 10,000 x 10,000?

I need to maintain quality because scaling is key, but loading the Image control seems to require something from 50 to 700 MB of memory usage: S

I am not doing anything particularly smart with loading an image at the moment:

BitmapImage imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.UriSource = new Uri(imageUrl, UriKind.Absolute);
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.EndInit();

image.Source = imageSource;
+3
source share
3 answers

Thus, there is a problem with memory leak / network stack problem when loading an image to a local disk, and then loading, which, apparently, reduces memory consumption by about 40%.

, . , DecodePixelWidth/Height, Jakob, , :)

+1

BitmapImage.DecodePixelHeight BitmapImage.DecodePixelWidth, , . XAML :

<Image>
    <Image.Source>
        <BitmapImage UriSource="http://server/image.jpg" DecodePixelWidth="400" />
    </Image.Source>
</Image>
+4

CacheMode.

cachemode 2048x2048. CacheMode . . , CacheMode xaml :

<Image Source="...">
    <Image.CacheMode>
        <BitmapCache ... />
    </Image.CacheMode>
</Image>

Lorenzo

0

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


All Articles