How to store image in memory more compact than usual Bitmap instance and access it fast enough?

帅比萌擦擦* 提交于 2019-12-12 03:18:11

问题


I have images like 5000*4000 pixels that I render every frame on form. Such image loaded like Bitmap bmp = Image.FromFile("test.png"); uses around 100 mb RAM, while file size is 40 - 50 mb! That way my prog already uses ~500 bm RAM.

How to store that images more RAM efficient, but be able to cut parts from it fast enough? I have one huge image and cut parts from it to render according to view position. I call render method at 50 FPS and can't afford loading images from file every frame, since it too slow.

Is there any other way to store image in memory?


回答1:


You are stuck with having to have the uncompressed image loaded into memory if you wish to display it and manipulate it. There is no way round this.

The only sure way to reduce this is to reduce the resolution of the image being displayed. You could store the compressed image in memory and uncompress it from memory rather than from disk each time you need to change it.

Having said that 500MB of RAM is not that much these days where computers have several GB of RAM available.



来源:https://stackoverflow.com/questions/34656453/how-to-store-image-in-memory-more-compact-than-usual-bitmap-instance-and-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!