←Select platform

GetOverlayImage Method

Summary
Gets the overlay image for the specified index.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterImage GetOverlayImage( 
   int index, 
   RasterGetSetOverlayImageMode mode 
) 
- (nullable LTRasterImage *)getOverlayForImageAtIndex:(NSInteger)index  
                                                 mode:(LTRasterGetSetOverlayImageMode)mode  
                                                error:(NSError **)error 
public RasterImage getOverlayImage( 
   int index, 
   RasterGetSetOverlayImageMode mode 
); 
public void setOverlayImage( 
   int intValue, 
   RasterImage rasterImage, 
   RasterGetSetOverlayImageMode rasterGetSetOverlayImageMode 
); 
public: 
RasterImage^ GetOverlayImage(  
   int index, 
   RasterGetSetOverlayImageMode mode 
)  
def GetOverlayImage(self,index,mode): 

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 retrieve the image, possible values are:

Mode Description
RasterGetSetOverlayImageMode.Copy A copy of the overlay image is retrieved from the overlay list.
RasterGetSetOverlayImageMode.NoCopy The actual overlay image is retrieved. No copy is made. You should be careful when modifying the returned overlay image because you can modify/invalidate the entry in the overlay bitmap list.
RasterGetSetOverlayImageMode.Move The actual overlay image is retrieved. The image is also removed from the overlay list. This is recommended over RasterGetSetOverlayImageMode.NoCopy.

Return Value

A RasterImage object that represents the overlay image of the specified index.

Remarks

This method is available in the (Document/Medical only) Toolkits.

This method can be used to get a copy of the overlay image (RasterGetSetOverlayImageMode.Copy) or to get the image without making a copy (RasterGetSetOverlayImageMode.NoCopy or RasterGetSetOverlayImageMode.Move).

The quickest way to get the overlay image is to avoid making a copy. For more information on using RasterGetSetOverlayImageMode.NoCopy, refer to the "Remarks" section of SetOverlayImage.

For more information, refer to Overlay Overview.

Example
C#
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 Leadtools.Svg; 
 
 
public void GetOverlayImageExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   // load an image and set an overlay 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm"), 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); 
   RasterImage imageOverlay1 = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ulay1.bmp"), 1, CodecsLoadByteOrder.Rgb, 1, 1); 
   RasterImage imageOverlay2 = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ulay1.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 LeadPoint(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(Path.Combine(LEAD_VARS.ImagesDir, "overlay{0}_copy.bmp"), i); 
         codecs.Save(overlayTest, fileName, RasterImageFormat.Bmp, 1); 
      } 
   } 
 
   image.Dispose(); 
   imageOverlay1.Dispose(); 
   imageOverlay2.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.5.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.