我使用EDSK将内存流转换为图像,它在
处出现以下错误错误:尝试读取或写入受保护的内存。这通常是一个 表明其他内存已损坏。
行:readStream.Read(outMessage,0,(int)streamLength);
unsafe
{
uint streamLength;
if (Error == EDSDK.EDS_ERR_OK)
{
Error = EDSDK.EdsGetLength(streamRef, out streamLength);
if (Error == EDSDK.EDS_ERR_OK)
{
UnmanagedMemoryStream readStream = new UnmanagedMemoryStream((byte*)(void*)streamRef.ToPointer(), streamLength, streamLength, FileAccess.Read);
// Create a byte array to hold data from unmanaged memory.
byte[] outMessage = new byte[streamLength];
// Read from unmanaged memory to the byte array.
readStream.Read(outMessage, 0, (int)streamLength);
readStream.Close();
Image img = byteArrayToImage(outMessage);
img.Save("C:\\temp\\test.jpeg");
}
}