How to handle huge tifs in WPF?

I have 8bit tiff thats 14406x9606 pixels, which when loading via BitmapImage throws a System.OutOfMemoryException. Like a full-sized bitmap of about 400 megabytes in size. Is there a way to split the image into more manageable pieces? I tried using DecodePixelHeight to load it with a lower resolution, and it works, but then I need to reboot every time the zoom changes. Are there any installed tools for working with really large images in WPF at different zoom levels?

+4
source share
2 answers

There is nothing inline that handles this directly. DecodePixelHeight , as you mentioned, is probably the best option in the structure itself.

However, you can use something like C # wrappers for GDAL . GDAL processes very large TIFF files, including those with pyramids, and allows you to (very quickly) open TIFF at various resolutions without loading the entire file into memory. This will still require an update / reboot when changing the resolution, but the TIFF download speed is quite a bit faster than the wireframe rendering classes, as it is designed to handle extremely large images.

+1
source

You might want to try LibTiff.Net . It is written in pure C # code, free, open source (BSD commercial license).

LibTiff.Net can process TIFF files up to 4 GB in size and can be used to open files without decoding all samples. The library also supports files with multiple stripes and tiled TIFFs.

Disclaimer: I am one of the developers of the library.

+1
source

Source: https://habr.com/ru/post/1341359/


All Articles