Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET BitmapSource is locking file

Tags:

c#

.net

I am using this C# code to access an image file in order to read metadata from it.

BitmapSource img = BitmapFrame.Create(uri);

Unfortunately the image file specified by uri becomes locked until the program ends. How do I prevent the image from being locked?

like image 287
Liam Avatar asked Apr 21 '26 18:04

Liam


1 Answers

maybe this could help ?

edit

BitmapSource img = BitmapFrame.Create(uri,BitmapCreateOptions.None,BitmapCacheOption.OnLoad);

BitmapCreateOptions.None = default option

BitmapCacheOption.OnLoad = Caches the entire image into memory at load time. All requests for image data are filled from the memory store.

from here

like image 58
Fredou Avatar answered Apr 24 '26 08:04

Fredou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!