Indicates which method should be called when an overlay is detected inside a file.
Syntax
Parameters
- callback
- The method which should be called when an overlay is detected. Use a null reference (Nothing in
Visual Basic) to indicate that LEADTOOLS should handle overlays automatically.
- mode
- Indicates when should this method be called. See CodecsOverlayCallbackMode for possible
values.
Example
Visual Basic | Copy Code |
---|
RasterCodecs.StartOverlay
Private Sub PtokaOverlayExample(ByVal ptokaFileName As String, ByVal ptokaFilesPath As String)
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim destFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\PtokaOverlay.tif"
myCodecs = codecs
myPtokaFilesPath = ptokaFilesPath
codecs.StartOverlay(AddressOf MyOverlayCallback, CodecsOverlayCallbackMode.CallLoad)
Dim image As RasterImage = codecs.Load(ptokaFileName)
codecs.StopOverlay()
codecs.Save(image, destFileName, RasterImageFormat.Tif, 1)
image.Dispose()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub
Private myCodecs As RasterCodecs
Private myPtokaFilesPath As String
Private Sub MyOverlayCallback(ByVal data As CodecsOverlayData)
Console.WriteLine("File: {0}", data.FileName)
Console.WriteLine("Page Number: {0}", data.PageNumber)
Console.WriteLine("Info: {0}", data.Info)
Dim overlayFileName As String = Path.Combine(myPtokaFilesPath, data.FileName)
If data.Info Then
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
data.Image = myCodecs.Load(overlayFileName)
End If
End Sub |
C# | Copy Code |
---|
RasterCodecs.StartOverlay void PtokaOverlayExample(string ptokaFileName, string ptokaFilesPath) { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); string destFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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.Shutdown(); } 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); } } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also