When does the .NET FW BitmapImage class load / cache?

I got a little confused in this class, I was hoping that someone could shed some light. I know that when loading it depends on the BitmapCreateOptions of the image.

However, when creating an absolute BitmapImage, say:

var Image = new BitmapImage(new Uri("http://...", UriKind.Absolute))

It will not download it immediately, because DelayCreation defaults to BitmapCreateOptions , right?

What to do, if:

var Image = new BitmapImage(new Uri("http://...", UriKind.Absolute))
Image.CreateOptions = BitmapCreateOptions.None;

Will the image load right after installing BitmapCreateOptions? If so, then this has the same behavior, right?

var Image = new BitmapImage(new Uri("http://...", UriKind.Absolute)) { CreateOptions = BitmapCreateOptions.None }

So how does caching work for BitmapImage ?

  • When does BitmapImage get cached?
  • , . "" , . "" ?
  • / ?
  • , Windows Phone?

, , ImageOpened ImageFailed ?

+4
1

, , , EndInit, . , , .

:

var Image = new BitmapImage(new Uri("http://...", UriKind.Absolute));
// The image is now intialized and is downloading/downloaded
Image.CreateOptions = BitmapCreateOptions.None; // nothing happens here

, , :

var Image = new BitmapImage();

Image.BeginInit();
Image.UriSource = new Uri("http://...", UriKind.Absolute)
Image.CreateOptions = BitmapCreateOptions.None; // This is default anyway so it won't affect
// ..Setting other properties...
Image.EndInit();
+1

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


All Articles