DicomImageInsertPage Method
Inserts a new page into the page list at the specified index.

Namespace: Aspose.Imaging.FileFormats.Dicom
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.06
Syntax
public DicomPage InsertPage(
	int pageIndex
)

Parameters

pageIndex
Type: SystemInt32
Index of the page.

Return Value

Type: DicomPage
The newly created DicomPage.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionpageIndex - Page index is less than 0. or pageIndex - Page index is greater than PageCount.
Examples
Create a multi-page Dicom image.
[C#]

using (DicomImage image = (DicomImage)Image.Create(
        new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
        100,
        100))
{
    // Draw something using vector graphics
    Graphics graphics = new Graphics(image);
    graphics.FillRectangle(new SolidBrush(Color.BlueViolet), image.Bounds);
    graphics.FillRectangle(new SolidBrush(Color.Aqua), 10, 20, 50, 20);
    graphics.FillEllipse(new SolidBrush(Color.Orange), 30, 50, 70, 30);

    // Save the pixels of the drawn image. They are now on the first page of the Dicom image.
    int[] pixels = image.LoadArgb32Pixels(image.Bounds);

    // Add a few pages after, making them darker
    for (int i = 1; i < 5; i++)
    {
        DicomPage page = image.AddPage();
        page.SaveArgb32Pixels(page.Bounds, pixels);
        page.AdjustBrightness(i * 30);
    }

    // Add a few pages in front of the main page, making them brighter
    for (int i = 1; i < 5; i++)
    {
        DicomPage page = image.InsertPage(0);
        page.SaveArgb32Pixels(page.Bounds, pixels);
        page.AdjustBrightness(-i * 30);
    }

    // Save the created multi-page image to the output file
    image.Save("MultiPage.dcm");
}
See Also