我试图将图像保存为a MemoryStream但在某些条件下失败.
这是代码:
以下代码成功:
Image img = Bitmap.FromStream(fileStream);
MemoryStream ms = new MemoryStream();
img.Save(ms, img.RawFormat); // This succeeds.
Run Code Online (Sandbox Code Playgroud)
以下代码失败:
Image img = Bitmap.FromStream(fileStream);
Image thumb = img.GetThumbnailImage(thumbWidth, thumbHeight, null, System.IntPtr.Zero);
MemoryStream ms = new MemoryStream();
thumb.Save(ms, thumb.RawFormat); // This fails.
Run Code Online (Sandbox Code Playgroud)
请注意,第二个片段正在使用使用创建的图像Image.GetThumbnailImage.
有什么不同?有谁知道它为什么失败?