-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
- .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use
dotnet --info
)
5.0.201 - Windows version: (
winver
)
19042.867 - Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No
Yes.
Problem description:
BitmapDecoder.Create
throws ArgumentException
("Value does not fall within the expected range.") whenever the stream argument is FileStream
with FileOptions.Asynchronous
.
Actual behavior:
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapDecoder.Create(Stream bitmapStream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
Expected behavior:
BitmapDecoder.Create
shouldn't throw an exception.
Minimal repro:
using var fs = new FileStream("image.jpg",
FileMode.Open,
FileAccess.Read,
FileShare.Read,
4096,
FileOptions.Asynchronous);
var decoder = BitmapDecoder.Create(fs, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
lindexi