Helper class for SoImageDataAdapter.
More...
#include <ImageViz/SbImageDataAdapterHelper.h>
Static Public Member Functions | |
static SoImageDataAdapter * | getAppropriateAdapter (const SbString &filename, size_t maxMemory=0) |
static void | saveToFile (SoImageDataAdapter *image, const SbString &filename) |
Contains various utility methods.
SoImageDataAdapter, SoFileDataAdapter, SoMemoryDataAdapter, SoVolumeReaderAdapter
InteractiveThresholding, OverlayDisplay, CreatingImage2D, CreatingImage3D, ExtractingROI
static SoImageDataAdapter* SbImageDataAdapterHelper::getAppropriateAdapter | ( | const SbString & | filename, | |
size_t | maxMemory = 0 | |||
) | [static] |
Loads data and returns a preconfigured SoImageDataAdapter instance based on the given filename extension.
If no SoImageDataAdapter is available for this extension or an error occurs, then NULL is returned.
filename | File (or directory) to load | |
maxMemory | If the data is smaller than the specified maximum memory in MB (default 500 MB), getAppropriateAdapter() will load the data in memory and return an SoMemoryDataAdapter. Access to data will be faster using an SoMemoryDataAdapter than a file based adapter. |
Returns: If possible (depending on memory limit), returns an SoMemoryDataAdapter object.
If this is not possible, returns an SoFileDataAdapter for simple image formats like JPEG or an SoVolumeReader for complex formats like DICOM (note that this requires initializing the VolumeViz extension!). The application can use dynamic_cast or getTypeId() to identify the type.
Important:
static void SbImageDataAdapterHelper::saveToFile | ( | SoImageDataAdapter * | image, | |
const SbString & | filename | |||
) | [static] |
Save given image to a file.
Filetype is determined by filename extension.
Supported formats are:
Any other file extension will result in throwing an exception. A time series (getSize()[3] > 1) will result in throwing an exception.
This is just a convenience method. Other formats may be written using subclasses of SoRasterImageRW or by accessing the data (see SbImageDataAccessor) and writing explicitly.