Replaces an existing page in this RasterImage.
public void ReplacePage(int index,RasterImage image)
Public Sub ReplacePage( _ByVal index As Integer, _ByVal image As Leadtools.RasterImage _)
public void ReplacePage(int index,Leadtools.RasterImage image)
- (void)replacePageAtIndex:(NSInteger)indexwithPage:(LTRasterImage *)page
function Leadtools.RasterImage.ReplacePage(index ,image)
public:void ReplacePage(int index,Leadtools.RasterImage^ image)
index
The 1-based index of the page from image to replace. If index is equal to -1, the last page in the image will be replaced.
image
The source image to replace with.
This method pulls the current active page of image and inserts into the current RasterImage object at page number = index. The number of pages in image is decremented by one, if image had only one page prior to calling this method, then the image object is disposed of and should not be used afterwards.
The RasterImage object can hold multiple pages with different sizes. The AddPage, AddPages, InsertPage and InsertPages methods allows adding new pages to an existing RasterImage.
The RemovePageAt, RemovePages and RemoveAllPages methods allows removing existing pages from a RasterImage object.
The ReplacePage and ReplacePages methods allows replace existing pages in a RasterImage object.
The PageCount property holds the total number of pages in a RasterImage object while the Page property allows you to change the current active page.
The current active page (The page indicated by the Page property) is used by default when accessing the data of a RasterImage object unless otherwise indicated.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using LeadtoolsExamples.Common;using Leadtools.Svg;public void TestReplacePage(){// Create a mult-page image from the following files:string[] pageFileNames ={Path.Combine(ImagesPath.Path,"Sample1.cmp"),Path.Combine(ImagesPath.Path,"Sample2.cmp"),Path.Combine(ImagesPath.Path,"Sample3.cmp"),Path.Combine(ImagesPath.Path,"Sample4.cmp")};string newPageFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");RasterCodecs codecs = new RasterCodecs();RasterImage image = null;foreach (string pageFileName in pageFileNames){RasterImage page = codecs.Load(pageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);if (image != null){image.AddPage(page);}else{image = page;}}// Show the image nowShowMultiPageImageInfo("Original image", image);// Load the page to replaceRasterImage newPage = codecs.Load(newPageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);Console.WriteLine("Loaded a new page of size {0} by {1}", newPage.Width, newPage.Height);// Replace the second page on the image with this pageimage.ReplacePage(2, newPage);// Show the list nowShowMultiPageImageInfo("New image after replacing page number 2", image);image.Dispose();codecs.Dispose();}private static void ShowMultiPageImageInfo(string message, RasterImage image){Console.WriteLine(message);int savePage = image.Page;for (int i = 1; i <= image.PageCount; i++){image.Page = i;Console.WriteLine(" {0}: Size {1} by {2} pixels", i, image.Width, image.Height);}image.Page = savePage;Console.WriteLine("----------------");}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub TestReplacePage()' Create a mult-page image from the following files:Dim pageFileNames() As String ={Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp"),Path.Combine(LEAD_VARS.ImagesDir, "Sample2.cmp"),Path.Combine(LEAD_VARS.ImagesDir, "Sample3.cmp"),Path.Combine(LEAD_VARS.ImagesDir, "Sample4.cmp")}Dim newPageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim codecs As New RasterCodecs()Dim image As RasterImage = NothingFor Each pageFileName As String In pageFileNamesDim page As RasterImage = codecs.Load(pageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)If Not IsNothing(image) Thenimage.AddPage(page)Elseimage = pageEnd IfNext' Show the image nowShowMultiPageImageInfo("Original image", image)' Load the page to replaceDim newPage As RasterImage = codecs.Load(newPageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)Console.WriteLine("Loaded a new page of size {0} by {1}", newPage.Width, newPage.Height)' Replace the second page on the image with this pageimage.ReplacePage(2, newPage)' Show the list nowShowMultiPageImageInfo("New image after replacing page number 2", image)image.Dispose()codecs.Dispose()End SubPrivate Shared Sub ShowMultiPageImageInfo(ByVal message As String, ByVal image As RasterImage)Console.WriteLine(message)Dim savePage As Integer = image.PageFor i As Integer = 1 To image.PageCountimage.Page = iConsole.WriteLine(" {0}: Size {1} by {2} pixels", i, image.Width, image.Height)Nextimage.Page = savePageConsole.WriteLine("----------------")End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
