The DICOM format is not designed for an easy insertion of pages. The following issues exist:
- Pages are stored sequentially rather than in arbitrary order. If the image is compressed, replacing a page requires rewriting all subsequent pages.
- "Number of pages" tag is stored as "Integer string". If, for example, tag is equal to "99", adding a page requires to increase length of this tag, and thus requires rewriting of the whole image.
- All pages in the file must have the same dimensions and compression.
- Some DICOM modalities support multiframe images, while others don't.
According to the above issues, DICOM format filter in ImageGear for .NET has the following limitations:
- Only APPEND and OVERWRITE saving modes are supported.
- ImageGear for .NET allows appending a page to a DICOM file only if the file already has "Number Of Pages" tag, and this tag has maximum possible length for an Integer String: 12 bytes.
- Page being saved must have the same dimensions and compression as existing pages in the file.
- ImageGear does not check if image's modality allows multipage images.
If any of the limitations is encountered, ImageGear throws an exception.
To save a multipage image:
- Load an image to ImageGear for .NET.
- Save image to a new file (or use OVERWRITE mode).
- Load next image to ImageGear for .NET.
- Save image to existing file, using APPEND mode.
- Repeat steps 3 and 4 for all pages to be written.
Alternatively, create an ImGearDocument Class and save to DICOM using the SaveDocument Method.