.NET GDI+ image size - file codec limitations

那年仲夏 提交于 2019-12-01 04:58:55

The problem you are facing is very likely the following limitation in the .NET Framework: the maximum object size allowed in the GC Heap is 2GB, even on 64-bit OS / builds.

Some references: link, link, link.

Depending on your needs, with a relatively simple (uncompressed) format like TIFF it might be doable to generate your image in parts and merge the parts afterwards. Just an idea..

From the TIFF specification Section 2: TIFF Structure at at http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf:

TIFF is an image file format. In this document, a file is defined to be a sequence of 8-bit bytes, where the bytes are numbered from 0 to N. The largest possible TIFF file is 2**32 bytes in length.

Unfortunately many TIFF writers and readers use signed integers in implementation and reduce the practical size to 2**31. This is compounded by the frequent attempt by drivers to keep the entire image in memory as mentioned by Cristophe.

You are likely to find similar limitations in the other image formats created in the '80s or earlier. Multi gigabyte file size limits were not considered a problem when disks were only in the tens of megabytes.

So your goal is to encode them into jpeg? I am sure there would be a way to pull in only the section you are encoding, then dispose and go on to the next section. If you open the file raw and and parse it yourself, I am sure there are open source jpeg encoders out there to help with creating the sections. This should allow you to encode files extremely large, but your will always have OS and filesystem hurdles to overcome.

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