←Select platform

UpdateOverlayBits Method

Summary
Updates the overlay image pixels with the bits from the corresponding bitplane of the main image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public void UpdateOverlayBits( 
   int index, 
   RasterUpdateOverlayBitsFlags flags 
) 
- (BOOL)updateOverlayBitFlags:(LTRasterUpdateOverlayBitsFlags)flags  
              forImageAtIndex:(NSInteger)index  
                        error:(NSError **)error 
public void updateOverlayBits( 
   int index, 
   RasterUpdateOverlayBitsFlags flags 
); 
public: 
void UpdateOverlayBits(  
   int index, 
   RasterUpdateOverlayBitsFlags flags 
)  
def UpdateOverlayBits(self,flags): 

Parameters

index
The index of the overlay used in the process.

flags
Flags that determine whether the main image or the overlay image should be updated.

Remarks

The image memory must be locked when you use this method. Normally, you can call Access to lock the memory before starting an operation that uses this method. Then call Release when the operation is finished.

This method can also update the main image's bitplane with the data from the overlay image.

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

The overlay at  index must have the corresponding bitplane set: otherwise, this method will throw a RasterException with RasterExceptionCode.OverlayIndex. This index is zero-based and should be less than or equal to MaxOverlays.

If RasterUpdateOverlayBitsFlags.FromOverlay is set in  flags, the bitplane in the main image will be updated to match the overlay image data. The left and top coordinates for the overlay image are used. If RasterUpdateOverlayBitsFlags.Clear is set, the bits from the bitplane associated with the overlay are set to 0 if they are not covered by the overlay. If RasterUpdateOverlayBitsFlags.Clear is not set, the bits from the bitplane associated with the overlay that are not covered by the overlay image are left unchanged.

If RasterUpdateOverlayBitsFlags.FromImage is set in  flags, the overlay image will be updated with the bits from the corresponding bitplane. The size of the overlay image is unchanged if it has ever been set. If the overlay image has never been set, the overlay image will be from left, top coordinate to the bottom-right corner of the image:

OverlayWidth = Image.ImageWidth - OverlayImage.Origin.X OverlayHeight = Image.ImageHeight - OverlayImage.Origin.Y

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.2.29
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.