HOWTO: Handle a Very Large TIFF Image

If you don't already know, DotImage has a limit on the size of images that it can load based on the current amount of free memory. This is because DotImage needs to lay out the image data into a continuous block of memory. So what if you just want to view a resampled version of a very large image? It is possible to do this with TIFF images because the TiffDecoder has a ReadRegion method, and the original article suggested doing this by chunking the image into 4 "tiles".

However, for some time, DotImage's TiffDecoder now includes this functionality directly.. you can simply use the TiffDecoder.ReadScaled method.

Example: lets say you have a tiff page that is 17000 pixels by 22000 pixels in size .. this would require a very large amount of memory to render (for a 1 bit per pixel 44 MiB of contiguous memory. but at 8 bit per pixel it would need a 256 MiB chunk.. and for 24 bit per pixel (color) just around 1GiB)

You could resample it down to 1700x2200 this way:

AtalaImage resampledImg;
using (FileStream fs = new FileStream("YourHugeTiffHere.tif", FileMode.Open, FileAccess.Read, FileShare.Read))
    TiffDecoder dec = new TiffDecoder();
    // since we're reading 1/10 the size we scale by 0.1
    // half size would be 0.5 etc..
    resampledImg = dec.ReadScaled(fs, frameIndex, 0.1d, null);

Original Article:
Q10139 - HOWTO: View a Very Large TIFF Image