Leadtools.Codecs Namespace > RasterCodecs Class : StartOverlay Method |
public void StartOverlay( CodecsOverlayCallback callback, CodecsOverlayCallbackMode mode )
'Declaration Public Sub StartOverlay( _ ByVal callback As CodecsOverlayCallback, _ ByVal mode As CodecsOverlayCallbackMode _ )
'Usage Dim instance As RasterCodecs Dim callback As CodecsOverlayCallback Dim mode As CodecsOverlayCallbackMode instance.StartOverlay(callback, mode)
public void StartOverlay( CodecsOverlayCallback callback, CodecsOverlayCallbackMode mode )
public: void StartOverlay( CodecsOverlayCallback^ callback, CodecsOverlayCallbackMode mode )
Currently, only PTOCA files are known to use such overlays.
PTOCA files contain file references (i.e. filenames) to external files that contain overlay bitmaps. (These files are typically in IOCA format)
These external overlay files will be resized and placed on the current page according to the information from the PTOCA files. By default, LEADTOOLS will load these external overlay files from disk. You should override this behavior if you load files that are not stored locally (for example, on a remote storage or in a database).
To load overlays stored on other storage, you have to pass your overlay callback to this method and load the overlays in your overlay callback.
The overlay callback will be used until StopOverlay is called.
Private Sub PtokaOverlayExample(ByVal ptokaFileName As String, ByVal ptokaFilesPath As String) Dim codecs As RasterCodecs = New RasterCodecs() Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "PtokaOverlay.tif") ' Set up the private variables used in the callback myCodecs = codecs myPtokaFilesPath = ptokaFilesPath ' Set the overlay callback codecs.StartOverlay(AddressOf MyOverlayCallback, CodecsOverlayCallbackMode.CallLoad) ' Load the PTOKA file Dim image As RasterImage = codecs.Load(ptokaFileName) ' Stop the overlay by resetting the old callback. codecs.StopOverlay() ' Save the image as TIFF codecs.Save(image, destFileName, RasterImageFormat.Tif, 1) image.Dispose() ' Clean up codecs.Dispose() End Sub Private myCodecs As RasterCodecs Private myPtokaFilesPath As String Private Sub MyOverlayCallback(ByVal data As CodecsOverlayData) ' Show overlay information Console.WriteLine("File: {0}", data.FileName) Console.WriteLine("Page Number: {0}", data.PageNumber) Console.WriteLine("Info: {0}", data.Info) ' Construct the overlay file name Dim overlayFileName As String = Path.Combine(myPtokaFilesPath, data.FileName) If data.Info Then ' Info, we only need to fill in the .InfoXXX members of the data Dim imageInfo As CodecsImageInfo = myCodecs.GetInformation(overlayFileName, False) data.InfoWidth = imageInfo.Width data.InfoHeight = imageInfo.Height data.InfoXResolution = imageInfo.XResolution data.InfoYResolution = imageInfo.YResolution Else ' We need to load the overlay image into the .Image member data.Image = myCodecs.Load(overlayFileName) End If End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
void PtokaOverlayExample(string ptokaFileName, string ptokaFilesPath) { RasterCodecs codecs = new RasterCodecs(); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "PtokaOverlay.tif"); // Set up the private variables used in the callback myCodecs = codecs; myPtokaFilesPath = ptokaFilesPath; // Set the overlay callback codecs.StartOverlay(MyOverlayCallback, CodecsOverlayCallbackMode.CallLoad); // Load the PTOKA file RasterImage image = codecs.Load(ptokaFileName); // Stop the overlay by resetting the old callback. codecs.StopOverlay(); // Save the image as TIFF codecs.Save(image, destFileName, RasterImageFormat.Tif, 1); image.Dispose(); // Clean up codecs.Dispose(); } RasterCodecs myCodecs; string myPtokaFilesPath; void MyOverlayCallback(CodecsOverlayData data) { // Show overlay information Console.WriteLine("File: {0}", data.FileName); Console.WriteLine("Page Number: {0}", data.PageNumber); Console.WriteLine("Info: {0}", data.Info); // Construct the overlay file name string overlayFileName = Path.Combine(myPtokaFilesPath, data.FileName); if (data.Info) { // Info, we only need to fill in the .InfoXXX members of the data CodecsImageInfo imageInfo = myCodecs.GetInformation(overlayFileName, false); data.InfoWidth = imageInfo.Width; data.InfoHeight = imageInfo.Height; data.InfoXResolution = imageInfo.XResolution; data.InfoYResolution = imageInfo.YResolution; } else { // We need to load the overlay image into the .Image member data.Image = myCodecs.Load(overlayFileName); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2