更新时间:2023-09-11 13:53:40
我最近认为是同样的问题。您需要跳过创建MemoryStream的using语句。创建位图会保留对创建它的流的引用。您可以在 MSDN 上阅读相关内容。
I had what I believe was the same problem recently. You need to skip the using statement around the creation of your MemoryStream. Creating a bitmap keeps a reference to the stream that created it. You can read about it on MSDN.
private static Bitmap LoadImageFromBytes(byte[] bytes)
{
var imageStream = new MemoryStream(bytes))
var image = (Bitmap)Bitmap.FromStream(imageStream);
return image;
}