Gets the overlay image for the specified index.
Syntax
Parameters
- index
- The index of the overlay being retrieved. This index is zero-based and should be less or equal
than MaxOverlays.
- mode
- Determines how to retreive the image, possible values are:
Return Value
A
RasterImage object that represents the overlay image of the specified index.
Example
Visual Basic | Copy Code |
---|
Public Sub GetOverlayImageExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE2.DIC", 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
Dim imageOverlay1 As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY1.BMP", 1, CodecsLoadByteOrder.Rgb, 1, 1)
Dim imageOverlay2 As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY2.BMP", 1, CodecsLoadByteOrder.Rgb, 1, 1)
image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy)
image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy)
Dim attributes As RasterOverlayAttributes = image.GetOverlayAttributes(0, RasterGetSetOverlayAttributesFlags.Color Or RasterGetSetOverlayAttributesFlags.Flags Or RasterGetSetOverlayAttributesFlags.Origin Or RasterGetSetOverlayAttributesFlags.BitIndex)
attributes.Color = New RasterColor(255, 255, 255)
attributes.AutoPaint = True
attributes.AutoProcess = True
attributes.Origin = New Point(5, 5)
attributes.BitPosition = image.BitsPerPixel - 1
image.UpdateOverlayAttributes(0, attributes, RasterGetSetOverlayAttributesFlags.Color Or RasterGetSetOverlayAttributesFlags.Flags Or RasterGetSetOverlayAttributesFlags.Origin Or RasterGetSetOverlayAttributesFlags.BitIndex)
Dim count As Integer = image.OverlayCount
Dim i As Integer = 0
Do While i < count
Dim overlayTest As RasterImage = image.GetOverlayImage(i, RasterGetSetOverlayImageMode.NoCopy)
Try
Dim fileName As String = String.Format(LeadtoolsExamples.Common.ImagesPath.Path + "overlay{0}_copy.bmp", i)
codecs.Save(overlayTest, fileName, RasterImageFormat.Bmp, 1)
Finally
CType(overlayTest, IDisposable).Dispose()
End Try
i += 1
Loop
image.Dispose()
imageOverlay1.Dispose()
imageOverlay2.Dispose()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void GetOverlayImageExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); // load an image and set an overlay RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE2.DCM", 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); RasterImage imageOverlay1 = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY1.BMP", 1, CodecsLoadByteOrder.Rgb, 1, 1); RasterImage imageOverlay2 = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY2.BMP", 1, CodecsLoadByteOrder.Rgb, 1, 1); image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy); image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy); // update the attributes of one of the overlays RasterOverlayAttributes attributes = image.GetOverlayAttributes(0, RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.BitIndex); attributes.Color = new RasterColor(255, 255, 255); attributes.AutoPaint = true; attributes.AutoProcess = true; attributes.Origin = new Point(5, 5); attributes.BitPosition = image.BitsPerPixel - 1; image.UpdateOverlayAttributes( 0, attributes, RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.BitIndex); int count = image.OverlayCount; for(int i = 0; i < count; i++) { using(RasterImage overlayTest = image.GetOverlayImage(i, RasterGetSetOverlayImageMode.NoCopy)) { string fileName = string.Format(LeadtoolsExamples.Common.ImagesPath.Path + "overlay{0}_copy.bmp", i); codecs.Save(overlayTest, fileName, RasterImageFormat.Bmp, 1); } } image.Dispose(); imageOverlay1.Dispose(); imageOverlay2.Dispose(); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also