views:

130

answers:

3

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 limitations (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)?

+1  A: 

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.

m0s
I'm already using OpenNetCF SDF, but overlooked the CreateImageEncoderToStream method. Will take a look on it and report any progress back..
Buthrakaur
+2  A: 

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.

leonbloy
that looks promising - I will try to rewrite it to .Net if I don't find any other method how to solve the problem. thanks
Buthrakaur
A: 

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

Buthrakaur