转换后,图像尺寸从11MB变为500MB?

时间:2014-04-18 00:07:52

标签: image f#

我在Format24bppArgb 11MB中有一个10,000px到10,000px的jpeg图像,但是在克隆它并将其保存为Format32bppArgb中的bmp之后,它上升到500MB,无论是什么原因?

let file = new Bitmap("planet.jpg")
let rect = new Rectangle(0, 0, file.Width, file.Height)
let img = file.Clone(rect, PixelFormat.Format32bppArgb)
img.Save("copy.bmp", ImageFormat.Bmp)

1 个答案:

答案 0 :(得分:0)

我继续在FSI中执行以下操作:

open System.Drawing
open System.Drawing.Imaging

let file = new Bitmap("planet.jpg")
let rect = new Rectangle(0, 0, file.Width, file.Height)
let img = file.Clone(rect, PixelFormat.Format32bppArgb)
img.Save("copy.bmp", ImageFormat.Bmp)

根据Windows资源管理器,我使用了一个空白的10,000px×10,000px JPG文件,时钟为1,563,127字节。结果copy.bmp为400,000,054字节,这确实比输入大很多。

正如@PaulAbbott所说,这是因为位图文件中没有压缩。每像素32位的10,000×10,000图像最终将被存储为3,200,000,000位,这正好是400,000,000字节或大约400 MB - 大约是您发布的大小。

如果您的文件确实是500 MB而不是400 MB左右,您可以尝试在某处托管吗?我想看看它,看看我在这里遗漏了什么。