2
votes

I need to generate some large graphs whose width and height can go up to millions of pixels in size. Please note that I do NOT want to scale down the image. Each point must represent one pixel.

Now using the Bitmap and Graphics objects, this is very much possible if I split the image into smaller squares but it is painfully slow.

I already calculate the pixel RGB values so was wondering if there is a way to create a byte array with these values and manually save them as an uncompressed BMP format file instead of dealing with the Bitmap class and the drawing functions of the Graphics class.

I am comfortable with unsafe code if that helps to speed up the process.

2
Do you mean "millions of pixels" total, like 1024 x 1024 is about a million pixels, or do you mean the dimensions are 1000000 x 1000000? If the latter, where do you plan to store the terabytes of image data?Greg Hewgill
I know I'm not helping but it would be what.. 1 Terabyte / image?Tipx
1 TB per image only if it's 256 color. 24 bit color would be 3 TB/image.David Yaw
(1) What is your use case? Different graphic file formats are used for specific business applications (e.g. DICOM for Radiology systems). (2) If this is general purpose, are you certain that vectors would not be a better solution?smartcaveman
What program do you plan to use to read such an image?Kevin Hsu

2 Answers

3
votes

If you're displaying graphs, why don't you use a technology like SVG that can be rendered on the fly with very little processing power, yet can scale to near-infinite sizes thanks to vector expansion?

2
votes

(While there is good question if anything will be able to read such files...)

BMP format is very simple - you can write it directly to disk (I'd recommend avoiding building huge file in memory unless you have other reasons to do so). There is a fixed-size header and then (for 24bpp) sequences of colors aligned on some width. Assuming you can pick width you will not even need to add any padding - just rows of colors for each pixel.