I need to generate large images (A4 image at 200 DPI, PNG format would be fine) in my compact framework application. This is impossible to do in standard way due to memory limitat开发者_如何学JAVAions (such big image will throw OOMException).
Is there any library which offers file-backed stream image generation?
Or I could generate many smaller stripes of images (each stripe representing a row of the large image) using standard Bitmap approach, but I need to merge them together afterwards - is there any method how to merge many smaller images into one large without having to instantiate large Bitmap instance (which would again cause OOM)?
I had a similar need myself, and I end writing my own library. PNGJ You may found it useful, it's Java but it should be easy to port to C# (completely independent of other libraries). It writes and reads PNG images (except paletted ones), line oriented, rather low level, optimized for handling huge images. There are some examples in the download.
Updated: I've made a C# available here: PNGCS
This is interesting... I did some googling for you, and the only useful thing I found is this OpenNETCF Smart Device Framework. The class library reference is here Suggest you to take a look at ImagingFactoryClass. CreateImageEncoderToStream method might be useful.
Merging approach would be cool if you had a library that would do it for you. I took a look at PNG specifications and its not very promising.
Good luck and I hope this helps.
I just made a quick basic implementation of PNG stream encoding class - it supports just 8bpp and grayscale at the moment though, but that's enough for my scenario. It should be quite easy to extend the class to support RGB and more color depths.
http://gist.github.com/393409
精彩评论