-
Notifications
You must be signed in to change notification settings - Fork 1.2k
BitmapDecoder.Create does not handle FileStream with FileOptions.Asynchronous #4355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The IWICImagingFactory_CreateDecoderFromFileHandle_Proxy function - Win32 apps | Microsoft Docs |
@lindexi thank you for taking a look. I assume there is no API for an async The fact that I was able to get around this issue by making a proxy stream, which wraps the original If so, maybe it's a good idea to disable this behavior whenever |
@vonzshik I agree with you. |
…rt Asynchronous [BitmapDecoder.Create does not handle FileStream with FileOptions.Asynchronous · Issue #4355 · dotnet/wpf](dotnet/wpf#4355 )
I write a demo to show the class Program
{
static void Main(string[] args)
{
CheckHResult(UnsafeNativeMethods.WICCodec.CreateImagingFactory(UnsafeNativeMethods.WICCodec.WINCODEC_SDK_VERSION,
out var pImagingFactory));
using var fs = new FileStream("image.jpg",
FileMode.Open,
FileAccess.Read,
FileShare.Read,
4096,
FileOptions.Asynchronous);
Guid vendorMicrosoft = new Guid(MILGuidData.GUID_VendorMicrosoft);
UInt32 metadataFlags = (uint)WICMetadataCacheOptions.WICMetadataCacheOnDemand;
CheckHResult
(
UnsafeNativeMethods.WICImagingFactory.CreateDecoderFromFileHandle
(
pImagingFactory,
fs.SafeFileHandle,
ref vendorMicrosoft,
metadataFlags,
out var decoder
)
);
}
static void CheckHResult(int hr)
{
if (hr < 0)
{
Exception exceptionForHR = Marshal.GetExceptionForHR(hr, (IntPtr)(-1));
throw exceptionForHR;
}
}
} |
[BitmapDecoder.Create does not handle FileStream with FileOptions.Asynchronous · Issue #4355 · dotnet/wpf](dotnet/wpf#4355 )
[BitmapDecoder.Create does not handle FileStream with FileOptions.Asynchronous · Issue dotnet#4355 · dotnet/wpf](dotnet#4355 )
…nchronous · Issue #4355 · dotnet/wpf](dotnet/wpf#4355 )
@vonzshik I fixed it, see #4966 I follow your opinion, when I judge this file is asynchronous, I read the file into memory. I wrote a demo code, and it work well. See https://github.com/lindexi/lindexi_gd/tree/20b78c5547b2ecacdd244a438ef58518469a91d7/GeafakaijawkeheahemLejeehocear You can test the demo by publish the code with self contained.
|
[BitmapDecoder.Create does not handle FileStream with FileOptions.Asynchronous · Issue dotnet#4355 · dotnet/wpf](dotnet#4355 ) (cherry picked from commit 94ba24a)
We have taken this PR for the current Community Test Pass. Thanks for the contribution. |
dotnet --info
)5.0.201
winver
)19042.867
Yes.
Problem description:
BitmapDecoder.Create
throwsArgumentException
("Value does not fall within the expected range.") whenever the stream argument isFileStream
withFileOptions.Asynchronous
.Actual behavior:
Expected behavior:
BitmapDecoder.Create
shouldn't throw an exception.Minimal repro:
The text was updated successfully, but these errors were encountered: