You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.
Calling TextureLoader.LoadBitmap() results in the target file being locked for the lifetime of the process. This is because it does not dispose of the BitmapDecoder or BitmapDecodeFrame objects that it creates.
The code below fixed for me:
public static BitmapSource LoadBitmap(ImagingFactory factory, string filename) {
using (var bitmapDecoder = CreateBitmapDecoder(factory, filename)) {
using (var frame = bitmapDecoder.GetFrame(0)) {
var formatConverter = new FormatConverter(factory);
formatConverter.Initialize(
frame,
PixelFormat.Format32bppPRGBA,
BitmapDitherType.None,
null,
0.0,
BitmapPaletteType.Custom);
return formatConverter;
}
}
}
private static BitmapDecoder CreateBitmapDecoder(ImagingFactory factory, string filename) {
return new BitmapDecoder(
factory,
filename,
DecodeOptions.CacheOnDemand);
}
The text was updated successfully, but these errors were encountered:
Calling TextureLoader.LoadBitmap() results in the target file being locked for the lifetime of the process. This is because it does not dispose of the BitmapDecoder or BitmapDecodeFrame objects that it creates.
The code below fixed for me:
The text was updated successfully, but these errors were encountered: