Issue with BitmapEncoder and BitmapDecoder in Windows.Graphics.Imaging
Hi everyone,
I'm encountering an error while working with the Windows.Graphics.Imaging namespace. Here's the relevant code snippet:
using (Windows.Storage.Streams.InMemoryRandomAccessStream stream = new Windows.Storage.Streams.InMemoryRandomAccessStream())
{
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(
BitmapEncoder.BmpEncoderId, stream);
encoder.SetSoftwareBitmap(softwareBitmap);
await encoder.FlushAsync();
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
return await decoder.GetSoftwareBitmapAsync(
softwareBitmap.BitmapPixelFormat,
BitmapAlphaMode.Premultiplied,
new BitmapTransform { Rotation = BitmapRotation.Clockwise90Degrees, ...},...);
}
Error details:
- Message: invalid_pointer_read_c0000005_windows.graphics.dll!windows::graphics::imaging::ccreateencoderoperation::getresults
- Stack trace:
0 coreclr.dll EEPolicy::HandleFatalError 0x000000000000007D
1 coreclr.dll ProcessCLRException 0x000000000010A1CF
2 ntdll.dll RtlpExecuteHandlerForException 0x000000000000000F
3 ntdll.dll RtlDispatchException 0x0000000000000286
4 ntdll.dll KiUserExceptionDispatch 0x000000000000002E
5 Windows.Graphics.dll Windows::Graphics::Imaging::CCreateEncoderOperation::GetResults 0x000000000000007B
6 unknown.dll null 0x0000000000000000
7 unknown.dll null 0x0000000000000000
8 coreclr.dll PrestubWorkerEnd_V1 0x0000000000000000
9 unknown.dll null 0x0000000000000000
10 unknown.dll null 0x0000000000000000
11 unknown.dll noop 0x0000000000000000
12 unknown.dll null 0x0000000000000000
13 coreclr.dll vtable_InlinedCallFrame 0x0000000000000000
14 unknown.dll null 0x0000000000000000
I've already checked the following:
- The "softwareBitmap" object is properly initialized.
- The problem cannot be replicated in the development environment but occurs in certain users' environments.
Any insights or suggestions on how to troubleshoot this issue would be greatly appreciated!
Thanks in advance.