I have an image file that is 6 mb on disk.
When I load it using
Dim nBmp As Bitmap = Bitmap.FromFile(sPath)
... TaskManager shows an increase of used RAM of my app of around 200 mb.
I could confirm this because if I do this around 6 times, the RAM goes up to 1,2 GB, and further attempts to do that raise an out-of-memory error.
So it's actually true that so much is being used. I don't process this bitmap any further.
Why is the bitmap so much larger than the file on the disk?
答案 0 :(得分:3)
您正在加载压缩图像。 PNG在你的情况下。 Bitmap.FromFile
将对其进行解压缩,然后将其作为未压缩的Bitmap加载到内存中。这需要更多的空间。正如你在评论中所说:PNG为6MB,Bitmap为190MB。