C# Saving huge images

2020-08-23 04:03发布

问题:

I'm having difficulties when trying to save huge images with C# (I'm talking about over one gigabyte).

Basically I'm trying to do this in parts - I have around 200 bitmap sources and I need a way to combine them before or after encoding them to a .png file.

I know this is going to require lots of RAM unless I somehow stream the data directly from hard drive but I have no idea how to do this either.

Each bitmap source is 895x895 pixels so combining the images after encoding doesn't seem easy because C# doesn't let you create a bitmap with size of 13425 x 13425.

回答1:

This PngCs library (disclaimer: I'm the author) lets you read and write huge PNG images line by line, so that you don't need to keep the full image in memory; perhaps you find it useful.