I am implementing clipboard, and I want to allocate memory for png image one time. Is there some way to predict maximum size of png file?
相关问题
- How to create PNG images with more than 72dpi usin
- iOS (objective-c) compression_decode_buffer() retu
- Markdown to clipboard as rich text
- Need a way to load image file into Mac clipboard u
- Is there a public implemention of LZSS compression
相关文章
- Where does this quality loss on Images come from?
- How to add clipboard support to Matplotlib figures
- Read 16-bit PNG image file using Python
- Converting svg to png with inkscape command line f
- C# Saving huge images
- c# saving very large bitmaps as jpegs (or any othe
- Does using image sprites make sense in HTTP/2?
- How to extract zip file using dotnet framework 4.0
A PNG image includes several things:
Size of item 1 is fixed: 8 + 12 + 11 = 31 bytes
Size of item 2 (if required) is at most 12 + 3 * 256 = 780 bytes
Size of item 5 is fixed: 12 bytes
Item 3, raw pixels data, is usually the most important one. The filtered-uncompressed data amounts to
Where W=width in pixels, H=height in pixels, C=channels (3 if RGB, 1 if palette or grayscale, 4 if RGBA, 2 if GA), BPC=bits per channel (normally 8)
That is compressed with ZLIB. It's practically impossible to bound precisely the worst case compression rate. In practice, one might assume that in the worst case the compressed stream will have a few bytes more than the original. Then the item 3 size would be approximately bound by (again assuming a fairly small IDAT chunk size of 8192 bytes) by
Item 4 (ancillary chunk data) is practically impossible to bound.