提供有关此主题的背景信息。我正在尝试通过使用内存流将图像文件转换为 byte[] 以返回 memorystream.ToArray(); 但是,我注意到转换 inputBitmap -> byte[] -> outputBitmap 后图像质量下降。outputBitmap 的质量低于 inputBitmap。我将图像转换为 byte[] 的代码如下
MemoryStream mstream = new MemoryStream();
myImage.Save(mstream,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] buffer = mstream.ToArray();
Run Code Online (Sandbox Code Playgroud)
并将字节 [] 转换回图像,
MemoryStream mstream = new MemoryStream(buffer);
Image newImage = Image.FromStream(mstream);
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么会这样,并希望指导我纠正这个问题吗?请注意,在我使用 inputBitmap 作为我的 pictureBox.Image 之前,它的质量看起来很棒。但是从 byte[] 转换为 outputBitmap 后,将 outputBitmap 设置为我的 pictureBox.Image 变得有点模糊和质量低下。